Skip to content

Commit

Permalink
[WALL] Lubega / WALL-4977 / Enable wallets translations for Français …
Browse files Browse the repository at this point in the history
…(FR) (deriv-com#17092)

* feat: add french translations to wallets

* fix: default options desc

* fix: add more success footer button

* fix: get allowed languages mock

* fix: applied comments

* fix: design updates

* fix: wrap wallets in localize

* fix: subtasks

* fix: subtasks

* fix: additional kyc info form

* fix: cfd password modal tnc redirection language

* fix: modal button width

* fix: responsive ui issues

* fix: enter password hint

* Merge branch 'master' of github.com:binary-com/deriv-app into WALL-4977/wallets-french-translation

* fix: latest changes

* fix: tablet view issues

* fix: desktop desc size

* fix: message max width
  • Loading branch information
lubega-deriv authored Oct 28, 2024
1 parent c0f191d commit 8452b12
Show file tree
Hide file tree
Showing 48 changed files with 234 additions and 103 deletions.
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
);

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 = [
...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

0 comments on commit 8452b12

Please sign in to comment.