Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WALL] Lubega / WALL-4977 / Enable wallets translations for Français (FR) #17092

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
76b4d86
feat: add french translations to wallets
lubega-deriv Oct 7, 2024
7f24d98
fix: default options desc
lubega-deriv Oct 7, 2024
71e63b8
fix: add more success footer button
lubega-deriv Oct 7, 2024
b9b28a3
fix: get allowed languages mock
lubega-deriv Oct 7, 2024
ce65fca
fix: applied comments
lubega-deriv Oct 8, 2024
fe776f8
fix: design updates
lubega-deriv Oct 8, 2024
b93b124
fix: wrap wallets in localize
lubega-deriv Oct 8, 2024
eab980c
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 10, 2024
78ac9cb
fix: subtasks
lubega-deriv Oct 10, 2024
559e6a3
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 14, 2024
536744d
fix: subtasks
lubega-deriv Oct 14, 2024
58f9d9f
fix: additional kyc info form
lubega-deriv Oct 15, 2024
734981f
fix: cfd password modal tnc redirection language
lubega-deriv Oct 15, 2024
c7081b0
fix: modal button width
lubega-deriv Oct 15, 2024
5082d06
fix: responsive ui issues
lubega-deriv Oct 17, 2024
2dd9701
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 17, 2024
0340d93
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 17, 2024
cb1eaff
fix: enter password hint
lubega-deriv Oct 17, 2024
8e6f371
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 17, 2024
ac1e9e6
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 17, 2024
018b49a
fix: latest changes
lubega-deriv Oct 17, 2024
c9d254c
fix: tablet view issues
lubega-deriv Oct 18, 2024
1c13387
fix: desktop desc size
lubega-deriv Oct 18, 2024
22e1ecc
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-49…
lubega-deriv Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion __mocks__/translation.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ const useTranslations = () => ({

const localize = mockFn;

const getAllowedLanguages = jest.fn(() => ({ EN: 'English', VI: 'Tiếng Việt' }));
const getAllowedLanguages = jest.fn(unsupported_languages => {
if (unsupported_languages.includes('VI')) {
return { EN: 'English' };
}
return { EN: 'English', VI: 'Tiếng Việt' };
});

const getInitialLanguage = jest.fn(() => 'EN');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Redirect } from 'react-router-dom';
import { UNSUPPORTED_LANGUAGES, routes } from '@deriv/shared';
import { UNSUPPORTED_LANGUAGES, WALLETS_UNSUPPORTED_LANGUAGES, routes } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { useTranslations, getAllowedLanguages } from '@deriv-com/translations';
import FormSubHeader from '../../../Components/form-sub-header';
Expand All @@ -25,13 +25,9 @@ const LanguageSettings = observer(() => {
switchLanguage(language_key);
};

let allowed_languages: Record<string, string> = getAllowedLanguages(UNSUPPORTED_LANGUAGES);

if (has_wallet) {
allowed_languages = Object.fromEntries(
Object.entries(allowed_languages).filter(([language_key]) => ['EN', 'AR'].includes(language_key))
);
}
const allowed_languages: Record<string, string> = getAllowedLanguages(
has_wallet ? WALLETS_UNSUPPORTED_LANGUAGES : UNSUPPORTED_LANGUAGES
lubega-deriv marked this conversation as resolved.
Show resolved Hide resolved
);

return (
<div className='settings-language'>
Expand Down
6 changes: 1 addition & 5 deletions packages/api-v2/src/APIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ type APIContextData = {
const getWebSocketURL = () => {
const endpoint = getSocketURL();
const app_id = getAppId();
const initial_language = getInitialLanguage();
const wallet_allowed_languages = initial_language === 'EN' || initial_language === 'AR';
// fallback to EN if language on initial load is not EN/AR
const language = wallet_allowed_languages ? initial_language : 'EN';

const language = getInitialLanguage();
return `wss://${endpoint}/websockets/v3?app_id=${app_id}&l=${language}&brand=deriv`;
};

Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/App/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ThemeProvider } from '@deriv-com/quill-ui';
import { useGrowthbookGetFeatureValue, useGrowthbookIsOn, useLiveChat, useOauth2 } from '@deriv/hooks';
import { useTranslations } from '@deriv-com/translations';
import initHotjar from '../Utils/Hotjar';
import { WALLETS_UNSUPPORTED_LANGUAGES } from '@deriv/shared';

const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }) => {
const store = useStore();
Expand Down Expand Up @@ -55,7 +56,7 @@ const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }
const { data } = useRemoteConfig(true);
const { tracking_datadog } = data;
const is_passkeys_supported = browserSupportsWebAuthn();
const wallets_allowed_languages = current_language === 'EN' || current_language === 'AR';
const is_wallets_unsupported_language = WALLETS_UNSUPPORTED_LANGUAGES.includes(current_language);

const livechat_client_information: Parameters<typeof useLiveChat>[0] = {
is_client_store_initialized,
Expand Down Expand Up @@ -110,11 +111,18 @@ const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }
if (is_dark_mode_on) {
setDarkMode(false);
}
if (!wallets_allowed_languages) {
if (is_wallets_unsupported_language) {
changeSelectedLanguage('EN');
}
}
}, [has_wallet, current_language, changeSelectedLanguage, is_dark_mode_on, setDarkMode, wallets_allowed_languages]);
}, [
has_wallet,
current_language,
changeSelectedLanguage,
is_dark_mode_on,
setDarkMode,
is_wallets_unsupported_language,
]);

return (
<ThemeProvider theme={is_dark_mode_on ? 'dark' : 'light'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { observer, useStore } from '@deriv/stores';
import { getAllowedLanguages } from '@deriv-com/translations';
import { localize } from '@deriv/translations'; // [TODO:] Remove this once deriv-app is configured to use the new translation lib
import { LanguageLink } from 'App/Components/Routes';
import { UNSUPPORTED_LANGUAGES } from '@deriv/shared';
import { UNSUPPORTED_LANGUAGES, WALLETS_UNSUPPORTED_LANGUAGES } from '@deriv/shared';

type TMobileLanguageMenu = {
expandSubMenu: (prop: boolean) => void;
Expand All @@ -18,11 +18,9 @@ const MobileLanguageMenu = observer(({ expandSubMenu, toggleDrawer }: TMobileLan
const { has_wallet } = client;
const { is_mobile_language_menu_open, setMobileLanguageMenuOpen } = ui;

const allowed_languages = Object.keys(getAllowedLanguages(UNSUPPORTED_LANGUAGES));

const filtered_languages = has_wallet
? allowed_languages.filter(lang => lang === 'EN' || lang === 'AR')
: allowed_languages;
const allowed_languages = Object.keys(
getAllowedLanguages(has_wallet ? WALLETS_UNSUPPORTED_LANGUAGES : UNSUPPORTED_LANGUAGES)
);

return (
<MobileDrawer.SubMenu
Expand All @@ -40,7 +38,7 @@ const MobileLanguageMenu = observer(({ expandSubMenu, toggleDrawer }: TMobileLan
'settings-language__language-container--disabled': is_language_changing,
})}
>
{filtered_languages.map(lang => (
{allowed_languages.map(lang => (
<LanguageLink
key={lang}
is_clickable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { observer, useStore } from '@deriv/stores';
import { getAllowedLanguages, useTranslations } from '@deriv-com/translations';
import { LanguageLink } from 'App/Components/Routes';
import { UNSUPPORTED_LANGUAGES } from '@deriv/shared';
import { UNSUPPORTED_LANGUAGES, WALLETS_UNSUPPORTED_LANGUAGES } from '@deriv/shared';

const isCurrentLanguage = (lang, current_language) => lang === current_language;

Expand All @@ -12,16 +12,14 @@ const LanguageSettings = observer(() => {
const { toggleLanguageSettingsModal } = ui;
const { currentLang } = useTranslations();

const allowed_languages = Object.keys(getAllowedLanguages(UNSUPPORTED_LANGUAGES));

const filtered_languages = has_wallet
? allowed_languages.filter(lang => lang === 'EN' || lang === 'AR')
: allowed_languages;
const allowed_languages = Object.keys(
getAllowedLanguages(has_wallet ? WALLETS_UNSUPPORTED_LANGUAGES : UNSUPPORTED_LANGUAGES)
);

return (
<div className='settings-language'>
<div className='settings-language__language-container'>
{filtered_languages.map(lang =>
{allowed_languages.map(lang =>
isCurrentLanguage(lang, currentLang) ? (
<LanguageLink key={lang} lang={lang} />
) : (
Expand Down
25 changes: 25 additions & 0 deletions packages/shared/src/utils/constants/default-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,28 @@ import { isProduction } from '../config/config';
* Returns List of unsupported languages based on the environment.
*/
export const UNSUPPORTED_LANGUAGES = isProduction() ? ['ID', 'MN'] : ['MN'];

/**
* Returns List of unsupported languages for Wallets.
*/
export const WALLETS_UNSUPPORTED_LANGUAGES = [
lubega-deriv marked this conversation as resolved.
Show resolved Hide resolved
...UNSUPPORTED_LANGUAGES,
'BN',
'DE',
'ES',
'ID',
'IT',
'SW',
'KM',
'KO',
'PL',
'PT',
'RU',
'SI',
'TH',
'TR',
'UZ',
'VI',
'ZH_CN',
'ZH_TW',
];
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
padding-inline-end: 0.8rem;
width: 100%;

&__label {
@include mobile-or-tablet-screen {
max-width: 14rem;
}
}

&__input {
all: unset;
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const WalletTransferFormInputField: React.FC<TProps> = ({

return (
<div className='wallets-atm-amount-input'>
<Text align='start' size='sm'>
<Text align='start' className='wallets-atm-amount-input__label' size='sm'>
{label}
</Text>
<div className='wallets-atm-amount-input__input-container'>
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/src/components/Base/Tabs/TabTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const TabTitle: FC<TabTitleProps> = ({ icon, index, isActive, setSelectedTab, si
onClick={handleOnClick}
>
{icon}
<Text size={size} weight={isActive ? 'bold' : 'normal'}>
<Text align='center' size={size} weight={isActive ? 'bold' : 'normal'}>
{title}
</Text>
</button>
Expand Down
3 changes: 2 additions & 1 deletion packages/wallets/src/components/Base/Tabs/Tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
background: none;
padding: 1rem 0;
cursor: pointer;

&--active {
width: 50%;
border: none;
border-bottom: 0.2rem solid var(--brand-coral, #ff444f);
background: none;
padding: 1rem 0;
padding: 1rem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
position: absolute;
height: 100%;
top: 50%;
inset-inline-start: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

Expand Down
31 changes: 20 additions & 11 deletions packages/wallets/src/components/Base/WalletLink/WalletLink.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
import React from 'react';
import { getStaticUrl } from '../../../helpers/urls';
import { getInitialLanguage } from '@deriv-com/translations';
import { getStaticUrl, setUrlLanguage } from '../../../helpers/urls';
import './WalletLink.scss';

type TVariant = 'bold' | 'normal';

interface LinkProps {
children?: React.ReactNode;
href?: React.AnchorHTMLAttributes<HTMLAnchorElement>['href'];
language?: string;
staticUrl?: React.AnchorHTMLAttributes<HTMLAnchorElement>['href'];
variant?: TVariant;
}

const WalletLink: React.FC<LinkProps> = ({ children, href, staticUrl, variant = 'normal' }) => (
<a
className={`wallets-link wallets-link__variant--${variant}`}
href={href ?? (staticUrl ? getStaticUrl(staticUrl) : '#')}
rel='noopener noreferrer'
target='_blank'
>
{children}
</a>
);
const WalletLink: React.FC<LinkProps> = ({ children, href, language, staticUrl, variant = 'normal' }) => {
const getHref = () => {
setUrlLanguage(getInitialLanguage());
return getStaticUrl(staticUrl, language);
};

return (
<a
className={`wallets-link wallets-link__variant--${variant}`}
href={href ?? (staticUrl ? getHref() : '#')}
rel='noopener noreferrer'
target='_blank'
>
{children}
</a>
);
};

export default WalletLink;
4 changes: 4 additions & 0 deletions packages/wallets/src/components/Dropzone/Dropzone.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
border: 0.1rem solid var(--status-danger, #ec3f3f);
}

&__button {
height: auto;
}

&__content {
width: 100%;
height: 100%;
Expand Down
1 change: 1 addition & 0 deletions packages/wallets/src/components/Dropzone/Dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const Dropzone: React.FC<TProps> = ({
<div className='wallets-dropzone__placeholder-text'>
<Button
borderWidth='sm'
className='wallets-dropzone__button'
color='black'
onClick={open}
textSize={isDesktop ? 'sm' : 'md'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const OptionsAndMultipliersListing = () => {
</Text>
)}
<Text align='start' size={isDesktop ? 'md' : 'sm'}>
<Localize i18n_default_text='Predict the market, profit if you’re right, risk only what you put in. ' />
<Localize i18n_default_text='Predict the market, profit if you’re right, risk only what you put in.' />{' '}
<WalletLink staticUrl='/trade-types/options/digital-options/up-and-down/'>
<Localize i18n_default_text='Learn more' />
</WalletLink>
Expand Down
10 changes: 7 additions & 3 deletions packages/wallets/src/components/WalletCard/WalletCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ComponentProps } from 'react';
import classNames from 'classnames';
import { useTranslations } from '@deriv-com/translations';
import { Localize } from '@deriv-com/translations';
import { Text } from '@deriv-com/ui';
import useAllBalanceSubscription from '../../hooks/useAllBalanceSubscription';
import { WalletCurrencyIcon } from '../WalletCurrencyIcon';
Expand All @@ -25,7 +25,7 @@ const WalletCard: React.FC<TProps> = ({
onClick,
}) => {
const { isLoading: isBalanceLoading } = useAllBalanceSubscription();
const { localize } = useTranslations();
const isDemoCarouselContent = isDemo && isCarouselContent;

return (
<button
Expand Down Expand Up @@ -57,7 +57,11 @@ const WalletCard: React.FC<TProps> = ({
</div>
<div className='wallets-card__details-bottom'>
<Text color={isDemo ? 'white' : 'general'} size={isCarouselContent ? 'md' : '2xs'}>
{currency} {isDemo && isCarouselContent ? localize('Demo') : ''} Wallet
{isDemoCarouselContent ? (
<Localize i18n_default_text='{{currency}} Demo Wallet' values={{ currency }} />
) : (
<Localize i18n_default_text='{{currency}} Wallet' values={{ currency }} />
)}
</Text>
{isBalanceLoading ? (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const WalletListCardActions: React.FC<TProps> = ({ accountsActiveTabIndex }) =>
}}
size='lg'
/>
<Text size='sm' weight={button.text === localize('Deposit') ? 'bold' : 'normal'}>
<Text align='center' size='xs' weight={button.text === localize('Deposit') ? 'bold' : 'normal'}>
{button.text}
</Text>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEventListener, useOnClickOutside } from 'usehooks-ts';
import { useActiveWalletAccount, useWalletAccountsList } from '@deriv/api-v2';
import { displayMoney } from '@deriv/api-v2/src/utils';
import { LabelPairedChevronDownLgFillIcon } from '@deriv/quill-icons';
import { Localize } from '@deriv-com/translations';
import { Localize, useTranslations } from '@deriv-com/translations';
import { Text } from '@deriv-com/ui';
import useAllBalanceSubscription from '../../hooks/useAllBalanceSubscription';
import useWalletAccountSwitcher from '../../hooks/useWalletAccountSwitcher';
Expand All @@ -18,6 +18,7 @@ const WalletListCardDropdown = () => {
const { data: wallets } = useWalletAccountsList();
const { data: activeWallet } = useActiveWalletAccount();
const switchWalletAccount = useWalletAccountSwitcher();
const { localize } = useTranslations();
const dropdownRef = useRef<HTMLDivElement>(null);

const { data: balanceData, isLoading: isBalanceLoading } = useAllBalanceSubscription();
Expand All @@ -26,9 +27,12 @@ const WalletListCardDropdown = () => {
const [isOpen, setIsOpen] = useState(false);
const [selectedText, setSelectedText] = useState('');

const generateTitleText = useCallback((wallet: THooks.WalletAccountsList) => {
return `${wallet?.currency} Wallet`;
}, []);
const generateTitleText = useCallback(
(wallet: THooks.WalletAccountsList) => {
return localize('{{currency}} Wallet', { currency: wallet?.currency });
},
[localize]
);

const walletList = useMemo(() => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
gap: 2.4rem;
padding: 1.6rem;
width: 23.2rem;
height: 28.2rem;
height: 100%;
border-radius: 1.6rem;
flex-shrink: 0;
border: 0.1rem solid var(--system-light-5-active-background, #d6dadb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

&__success-footer {
width: 24rem;
width: 26rem;

@include mobile-or-tablet-screen {
width: 100%;
Expand Down
Loading
Loading