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-4549 / Wallets initial translations setup #16158

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cdede05
feat: draft wallet translations
lubega-deriv Jul 10, 2024
9c999c8
Merge branch 'master' of github.com:binary-com/deriv-app into lubega/…
lubega-deriv Jul 15, 2024
3263f10
feat: initial wallets translations setup
lubega-deriv Jul 15, 2024
0f62272
chore: clean up code
lubega-deriv Jul 15, 2024
0e4d41f
fix: resolve error
lubega-deriv Jul 15, 2024
4f1ae51
fix: resolve error
lubega-deriv Jul 15, 2024
24f2a7a
chore: update text component
lubega-deriv Jul 16, 2024
043301f
fix: env variables and language switcher
lubega-deriv Jul 16, 2024
8578180
Merge branch 'master' of github.com:binary-com/deriv-app into lubega/…
lubega-deriv Jul 16, 2024
55d4a0f
Merge branch 'wall-4549/wallets-init-translation' of github.com:binar…
lubega-deriv Jul 17, 2024
42d3d55
[WALL] Lubega/ WALL-4549 / Wallets multi language support (#16069)
lubega-deriv Jul 17, 2024
475b254
Merge branch 'master' of github.com:binary-com/deriv-app into lubega/…
lubega-deriv Jul 18, 2024
3011b1d
fix: update locked scenarios
lubega-deriv Jul 18, 2024
1cb4950
Merge branch 'wall-4549/wallets-init-translation' of github.com:binar…
lubega-deriv Jul 18, 2024
63b4fb9
[WALL] Lubega / Wallets translations update (#16112)
lubega-deriv Jul 18, 2024
ba62ca3
Merge branch 'master' of github.com:binary-com/deriv-app into lubega/…
lubega-deriv Jul 18, 2024
675d0a2
Merge branch 'master' into wall-4549/wallets-init-translation
nijil-deriv Jul 19, 2024
6c27b24
Merge branch 'master' of github.com:binary-com/deriv-app into lubega/…
lubega-deriv Jul 19, 2024
948c49b
Merge branch 'wall-4549/wallets-init-translation' of github.com:binar…
lubega-deriv Jul 19, 2024
2015cad
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
lubega-deriv Jul 23, 2024
cca77c0
fix: update github workflow
lubega-deriv Jul 23, 2024
df78425
fix: getWalletHeaderButtons format
lubega-deriv Jul 23, 2024
01d8bbd
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
lubega-deriv Jul 23, 2024
527fa8d
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
lubega-deriv Jul 24, 2024
a206fd4
Update index.js
lubega-deriv Jul 24, 2024
bbb4807
Update index.js
lubega-deriv Jul 24, 2024
b9a394e
Update index.js
lubega-deriv Jul 24, 2024
c6e5d64
Update index.js
lubega-deriv Jul 24, 2024
1b7cf9c
Update index.js
lubega-deriv Jul 24, 2024
afbb6b8
chore: remove eslint auto format
lubega-deriv Jul 24, 2024
cd2c700
chore: remove eslint auto format
lubega-deriv Jul 24, 2024
8dcc5d9
chore: test remove line
lubega-deriv Jul 24, 2024
01f9d7d
chore: test remove line
lubega-deriv Jul 24, 2024
f4ca4d2
chore: test remove line
lubega-deriv Jul 24, 2024
cbef392
chore: test remove line
lubega-deriv Jul 24, 2024
9ef9f20
chore: test remove line
lubega-deriv Jul 24, 2024
11d25cf
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
lubega-deriv Jul 25, 2024
5c4bd96
chore: update deriv-com/translations version
lubega-deriv Jul 25, 2024
138e175
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
lubega-deriv Jul 26, 2024
a84b3a7
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-45…
lubega-deriv Jul 30, 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
4 changes: 0 additions & 4 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ inputs:
description: 'Node environment'
required: false
default: 'test'
CROWDIN_WALLETS_API_KEY:
description: 'Crowdin wallets api key'
required: false
DATADOG_CLIENT_TOKEN:
description: 'Datadog client token'
required: false
Expand Down Expand Up @@ -64,7 +61,6 @@ runs:
- name: Build all packages
env:
NODE_ENV: ${{ inputs.NODE_ENV }}
CROWDIN_WALLETS_API_KEY: ${{ inputs.CROWDIN_WALLETS_API_KEY }}
DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }}
DATADOG_CLIENT_TOKEN_LOGS: ${{ inputs.DATADOG_CLIENT_TOKEN_LOGS }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
uses: "./.github/actions/build"
with:
NODE_ENV: production
CROWDIN_WALLETS_API_KEY: ${{ secrets.CROWDIN_WALLETS_API_KEY }}
IS_GROWTHBOOK_ENABLED: ${{ vars.IS_GROWTHBOOK_ENABLED }}
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
uses: "./.github/actions/build"
with:
NODE_ENV: production
CROWDIN_WALLETS_API_KEY: ${{ secrets.CROWDIN_WALLETS_API_KEY }}
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }}
IS_GROWTHBOOK_ENABLED: ${{ vars.IS_GROWTHBOOK_ENABLED }}
DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }}
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/sync-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
- master
schedule:
- cron: '0 */12 * * *'

jobs:
sync_translations:
permissions:
contents: write
runs-on: ubuntu-latest
environment: Staging
steps:
- name: Sync translations
- name: Sync accounts translations
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
with:
PROJECT_NAME: ${{ vars.ACC_R2_PROJECT_NAME }}
Expand All @@ -26,3 +26,15 @@ jobs:
R2_SECRET_ACCESS_KEY: ${{ secrets.ACC_R2_SECRET_ACCESS_KEY }}
R2_BUCKET_NAME: ${{ secrets.ACC_R2_BUCKET_NAME }}
PROJECT_SOURCE_DIRECTORY: "packages/account/src"
- name: Sync wallets translations
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
with:
PROJECT_NAME: ${{ vars.WALLETS_PROJECT_NAME }}
CROWDIN_BRANCH_NAME: staging
CROWDIN_PROJECT_ID: ${{ secrets.WALLETS_CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.ACC_CROWDIN_PERSONAL_TOKEN }}
R2_ACCOUNT_ID: ${{ secrets.ACC_R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.ACC_R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.ACC_R2_SECRET_ACCESS_KEY }}
R2_BUCKET_NAME: ${{ secrets.ACC_R2_BUCKET_NAME }}
PROJECT_SOURCE_DIRECTORY: "packages/wallets/src"
34 changes: 19 additions & 15 deletions __mocks__/translation.mock.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import React from 'react';

const replaceValue = (text, values) => {
const valueMatch = text.match(/{{(\w+)}}/);
if (valueMatch) {
const valueKey = valueMatch[1];
return values[valueKey] || text;
}
return text;
};

const Localize = ({ i18n_default_text, components = [], values = {} }) => {
// Split text into parts, extracting placeholders for components
// Split text into parts, extracting placeholders for components and values
const parts = i18n_default_text.split(/(<\d+>.*?<\/\d+>|{{\w+}})/g);

const replaceValues = text => {
return text.replace(/{{(\w+)}}/g, (match, key) => values[key] || match);
};

return (
<>
{parts.map((part, index) => {
// Handle component placeholders
// Replace component placeholders with actual components
const componentMatch = part.match(/<(\d+)>(.*?)<\/\1>/);

if (componentMatch) {
const componentIndex = parseInt(componentMatch[1]);
const content = replaceValue(componentMatch[2], values);

// Replace values wrapped in components with actual values
const content = replaceValues(componentMatch[2]);
const Component = components[componentIndex];
return Component ? React.cloneElement(Component, { key: index, children: content }) : content;
}
// Replace placeholders with actual values
return replaceValue(part, values);

// Replace value placeholders with actual values
const valueMatch = part.match(/{{(\w+)}}/);
if (valueMatch) {
const valueKey = valueMatch[1];
return values[valueKey] || part;
}
return part;
})}
</>
);
Expand All @@ -45,4 +49,4 @@ const localize = mockFn;

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

export { Localize, localize, useTranslations, getAllowedLanguages };
export { Localize, localize, useTranslations, getAllowedLanguages };
10 changes: 0 additions & 10 deletions packages/wallets/crowdin.yml

This file was deleted.

1 change: 1 addition & 0 deletions packages/wallets/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const baseConfigForPackages = require('../../jest.config.base');
module.exports = {
...baseConfigForPackages,
moduleNameMapper: {
'@deriv-com/translations': '<rootDir>/../../__mocks__/translation.mock.js',
'\\.(css|s(c|a)ss)$': '<rootDir>/../../__mocks__/styleMock.js',
'^.+\\.svg$': '<rootDir>/../../__mocks__/fileMock.js',
},
Expand Down
10 changes: 4 additions & 6 deletions packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
"scripts": {
"analyze:stats": "NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.js\" --profile --json=stats.json",
"analyze:build": "webpack-bundle-analyzer --no-open -m static -r treemap.html stats.json ./dist && webpack-bundle-analyzer -m json stats.json ./dist",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.js\" && npm run translate",
"build": "rimraf dist && NODE_OPTIONS='-r ts-node/register' webpack --progress --config \"./webpack.config.js\"",
"serve": "rimraf dist && concurrently \"cross-env BUILD_MODE='serve' NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config ./webpack.config.js\" \"tsc -w --noEmit --preserveWatchOutput\"",
"start": "rimraf dist && npm run test && npm run serve",
"translate": "sh ./scripts/update-translations.sh"
"start": "rimraf dist && npm run test && npm run serve"
},
"dependencies": {
"@deriv-com/analytics": "1.10.0",
"@deriv-com/translations": "1.3.4",
"@deriv-com/ui": "1.29.9",
"@deriv-com/utils": "^0.0.25",
"@deriv/api-v2": "^1.0.0",
"@deriv/integration": "^1.0.0",
"@deriv/quill-icons": "1.23.3",
"react-joyride": "^2.5.3",
"@deriv/utils": "^1.0.0",
"@tanstack/react-table": "^8.10.3",
"@zxcvbn-ts/core": "^3.0.4",
Expand All @@ -31,14 +30,13 @@
"downshift": "^8.2.2",
"embla-carousel-react": "8.0.0-rc12",
"formik": "^2.1.4",
"i18next": "^22.4.6",
"moment": "^2.29.2",
"qrcode.react": "^3.1.0",
"react": "^17.0.2",
"react-calendar": "^4.7.0",
"react-dom": "^17.0.2",
"react-dropzone": "11.0.1",
"react-i18next": "^11.11.0",
"react-joyride": "^2.5.3",
"react-router-dom": "^5.2.0",
"react-transition-group": "4.4.2",
"usehooks-ts": "^2.7.0",
Expand Down
59 changes: 0 additions & 59 deletions packages/wallets/scripts/update-translations.sh

This file was deleted.

29 changes: 19 additions & 10 deletions packages/wallets/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import React from 'react';
import { APIProvider } from '@deriv/api-v2';
import { initializeI18n, TranslationProvider } from '@deriv-com/translations';
import { ModalProvider } from './components/ModalProvider';
import AppContent from './AppContent';
import WalletsAuthProvider from './AuthProvider';
import './styles/fonts.scss';
import './index.scss';
import './translations/i18n';

const App: React.FC = () => (
<APIProvider standalone>
<WalletsAuthProvider>
<ModalProvider>
<AppContent />
</ModalProvider>
</WalletsAuthProvider>
</APIProvider>
);
const App: React.FC = () => {
const i18nInstance = initializeI18n({
cdnUrl: `${process.env.CROWDIN_URL}/${process.env.WALLETS_TRANSLATION_PATH}`, // 'https://translations.deriv.com/deriv-app-wallets/staging'
useSuspense: false,
});

return (
<APIProvider standalone>
<WalletsAuthProvider>
<ModalProvider>
<TranslationProvider defaultLang='EN' i18nInstance={i18nInstance}>
<AppContent />
</TranslationProvider>
</ModalProvider>
</WalletsAuthProvider>
</APIProvider>
);
};

export default App;
23 changes: 2 additions & 21 deletions packages/wallets/src/AppContent.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React, { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import React, { useEffect, useRef } from 'react';
import { useDerivAccountsList } from '@deriv/api-v2';
import { Analytics } from '@deriv-com/analytics';
import useAllBalanceSubscription from './hooks/useAllBalanceSubscription';
import { defineViewportHeight } from './utils/utils';
import { WalletLanguageSidePanel } from './components';
import { Router } from './routes';
import './AppContent.scss';

const AppContent: React.FC = () => {
const [isPanelOpen, setIsPanelOpen] = useState(false);
const { i18n } = useTranslation();
const { isSubscribed, subscribeToAllBalance, unsubscribeFromAllBalance } = useAllBalanceSubscription();
const { data: derivAccountList } = useDerivAccountsList();
const previousDerivAccountListLenghtRef = useRef(0);
Expand All @@ -28,20 +24,6 @@ const AppContent: React.FC = () => {
};
}, [derivAccountList?.length, isSubscribed, subscribeToAllBalance, unsubscribeFromAllBalance]);

useEffect(() => {
const handleShortcutKey = (event: globalThis.KeyboardEvent) => {
if (event.ctrlKey && event.key === 'p') {
setIsPanelOpen(prev => !prev);
}
};

window.addEventListener('keydown', handleShortcutKey);

return () => {
window.removeEventListener('keydown', handleShortcutKey);
};
}, [setIsPanelOpen]);

useEffect(() => {
defineViewportHeight();
}, []);
Expand All @@ -54,10 +36,9 @@ const AppContent: React.FC = () => {
}, []);

return (
<div className='wallets-app' key={`wallets_app_${i18n.language}`}>
<div className='wallets-app'>
<div className='wallets-modal-show-header-root' id='wallets_modal_show_header_root' />
<Router />
{isPanelOpen && <WalletLanguageSidePanel />}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { FC, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { Divider, Tab, Tabs } from '@deriv-com/ui';
import { CFDPlatformsList } from '../../features';
import useDevice from '../../hooks/useDevice';
Expand All @@ -15,7 +14,6 @@ type TProps = {

const AccountsList: FC<TProps> = ({ accountsActiveTabIndex, onTabClickHandler }) => {
const { isMobile } = useDevice();
const { t } = useTranslation();

const onChangeTabHandler = useCallback((activeTab: number) => onTabClickHandler?.(activeTab), [onTabClickHandler]);

Expand All @@ -27,11 +25,11 @@ const AccountsList: FC<TProps> = ({ accountsActiveTabIndex, onTabClickHandler })
onChange={onChangeTabHandler}
wrapperClassName='wallets-accounts-list'
>
<Tab className='wallets-accounts-list__tab' title={t('CFDs')}>
<Tab className='wallets-accounts-list__tab' title='CFDs'>
<CFDPlatformsList />
<Divider color='var(--wallets-banner-border-color)' />
</Tab>
<Tab className='wallets-accounts-list__tab' title={t('Options')}>
<Tab className='wallets-accounts-list__tab' title='Options'>
<OptionsAndMultipliersListing />
<Divider color='var(--wallets-banner-border-color)' />
</Tab>
Expand Down
Loading
Loading