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 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 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
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
3 changes: 2 additions & 1 deletion 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, 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 All @@ -41,7 +42,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 wallets_allowed_languages = !WALLETS_UNSUPPORTED_LANGUAGES.includes(current_language);
lubega-deriv marked this conversation as resolved.
Show resolved Hide resolved

React.useEffect(() => {
switchLanguage(current_language);
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
'BN',
'DE',
'ES',
'ID',
'IT',
'SW',
'KM',
'KO',
'MN',
'PL',
'PT',
'RU',
'SI',
'TH',
'TR',
'UZ',
'VI',
'ZH_CN',
'ZH_TW',
];
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: 30.8rem;
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
2 changes: 1 addition & 1 deletion packages/wallets/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ export type TProductForMarketDetails = NonNullable<

export type TTranslations = ReturnType<typeof useTranslations>;

export type TLanguageType = 'AR' | 'EN';
export type TLanguageType = 'AR' | 'EN' | 'FR';
Loading