From 1502acea5848104a875deffb41fa371b5bd4a515 Mon Sep 17 00:00:00 2001 From: dominhquang Date: Thu, 24 Aug 2023 17:05:52 +0700 Subject: [PATCH] [Issue-973]: Support multi-language for WalletConnect feature --- .../account/useGetAccountTitleByAddress.ts | 13 +++-- .../index.tsx | 6 +- .../WalletConnect/ConnectionDetail.tsx | 2 +- src/screens/Settings/index.tsx | 18 +++--- src/screens/Transaction/SendFundV2/index.tsx | 6 +- src/utils/i18n/en_US.ts | 10 +++- src/utils/i18n/vi_VN.ts | 52 ++++++++++-------- src/utils/i18n/zh_CN.ts | 55 ++++++++++--------- 8 files changed, 90 insertions(+), 72 deletions(-) diff --git a/src/hooks/account/useGetAccountTitleByAddress.ts b/src/hooks/account/useGetAccountTitleByAddress.ts index 5ed6b08d6..edbdd1b2f 100644 --- a/src/hooks/account/useGetAccountTitleByAddress.ts +++ b/src/hooks/account/useGetAccountTitleByAddress.ts @@ -4,6 +4,7 @@ import useGetAccountSignModeByAddress from 'hooks/screen/useGetAccountSignModeByAddress'; import { useMemo } from 'react'; import { AccountSignMode } from 'types/signer'; +import i18n from 'utils/i18n/i18n'; const useGetAccountTitleByAddress = (address?: string): string => { const signMode = useGetAccountSignModeByAddress(address); @@ -11,18 +12,18 @@ const useGetAccountTitleByAddress = (address?: string): string => { return useMemo((): string => { switch (signMode) { case AccountSignMode.LEDGER: - return 'Ledger account'; + return i18n.common.ledgerAccount; case AccountSignMode.ALL_ACCOUNT: - return 'All account'; + return i18n.common.allAccounts; case AccountSignMode.PASSWORD: - return 'Normal account'; + return i18n.common.normalAccount; case AccountSignMode.QR: - return 'QR signer account'; + return i18n.common.qrSignerAccount; case AccountSignMode.READ_ONLY: - return 'Watch-only account'; + return i18n.common.watchOnlyAccount; case AccountSignMode.UNKNOWN: default: - return 'Unknown account'; + return i18n.common.unknownAccount; } }, [signMode]); }; diff --git a/src/screens/Confirmations/variants/ConnectWalletConnectConfirmation/index.tsx b/src/screens/Confirmations/variants/ConnectWalletConnectConfirmation/index.tsx index c54278a51..013848b07 100644 --- a/src/screens/Confirmations/variants/ConnectWalletConnectConfirmation/index.tsx +++ b/src/screens/Confirmations/variants/ConnectWalletConnectConfirmation/index.tsx @@ -55,8 +55,8 @@ export const ConnectWalletConnectConfirmation = ({ request }: Props) => { const { isDeepLinkConnect } = useSelector((state: RootState) => state.settings); const nameSpaceNameMap = useMemo( (): Record => ({ - [WALLET_CONNECT_EIP155_NAMESPACE]: 'EVM networks', - [WALLET_CONNECT_POLKADOT_NAMESPACE]: 'Substrate networks', + [WALLET_CONNECT_EIP155_NAMESPACE]: i18n.common.evmNetworks, + [WALLET_CONNECT_POLKADOT_NAMESPACE]: i18n.common.substrateNetworks, }), [], ); @@ -177,7 +177,7 @@ export const ConnectWalletConnectConfirmation = ({ request }: Props) => { )} {isSupportCase && ( - + {Object.entries(namespaceAccounts).map(([namespace, value]) => { const { appliedAccounts, availableAccounts, networks, selectedAccounts } = value; diff --git a/src/screens/Settings/WalletConnect/ConnectionDetail.tsx b/src/screens/Settings/WalletConnect/ConnectionDetail.tsx index 110f26382..2a42f7ebd 100644 --- a/src/screens/Settings/WalletConnect/ConnectionDetail.tsx +++ b/src/screens/Settings/WalletConnect/ConnectionDetail.tsx @@ -82,7 +82,7 @@ export const ConnectionDetail = ({ setLoading(true); disconnectWalletConnectConnection(topic) .catch(() => { - toast.show('Fail to disconnect', { type: 'danger' }); + toast.show(i18n.message.failToDisconnect, { type: 'danger' }); }) .finally(() => { setLoading(false); diff --git a/src/screens/Settings/index.tsx b/src/screens/Settings/index.tsx index 77bcd76d2..609fd1308 100644 --- a/src/screens/Settings/index.tsx +++ b/src/screens/Settings/index.tsx @@ -220,6 +220,15 @@ export const Settings = ({ navigation: drawerNavigation }: DrawerContentComponen rightIcon={setting.rightIcon} key={setting.title} label={setting.title} + leftItemIcon={ + setting.title === i18n.header.walletConnect ? ( + } + /> + ) : undefined + } icon={setting.icon} backgroundColor={setting.backgroundColor} onPress={setting.onPress} @@ -235,15 +244,6 @@ export const Settings = ({ navigation: drawerNavigation }: DrawerContentComponen rightIcon={setting.rightIcon} key={setting.title} label={setting.title} - leftItemIcon={ - setting.title === i18n.header.walletConnect ? ( - } - /> - ) : undefined - } icon={setting.icon} backgroundColor={setting.backgroundColor} onPress={setting.onPress} diff --git a/src/screens/Transaction/SendFundV2/index.tsx b/src/screens/Transaction/SendFundV2/index.tsx index b1109a990..1d4a3bc70 100644 --- a/src/screens/Transaction/SendFundV2/index.tsx +++ b/src/screens/Transaction/SendFundV2/index.tsx @@ -963,7 +963,7 @@ export const SendFund = ({ render={({ field: { value, ref, onChange, onBlur } }) => ( - Next + {i18n.buttonTitles.next} )} {viewStep === 2 && ( @@ -1042,7 +1042,7 @@ export const SendFund = ({ } }} style={stylesheet.max}> - {Max} + {{i18n.common.max}} )} diff --git a/src/utils/i18n/en_US.ts b/src/utils/i18n/en_US.ts index b4df828d5..0917749e8 100644 --- a/src/utils/i18n/en_US.ts +++ b/src/utils/i18n/en_US.ts @@ -194,6 +194,11 @@ export const en = { evmNetworks: 'EVM networks', substrateNetworks: 'Substrate networks', networks: 'Networks', + ledgerAccount: 'Ledger account', + normalAccount: 'Normal account', + qrSignerAccount: 'QR signer account', + watchOnlyAccount: 'Watch-only account', + unknownAccount: 'Unknown account', }, title: { exportAccount: 'Export account', @@ -601,9 +606,10 @@ export const en = { connectedNetworkConnected: (chainLength: number) => `${chainLength} networks connected`, connectedAccounts: (accountItemsLength: number) => `${accountItemsLength} account connected`, connectWalletConnectMessage: 'By clicking "Connect", you allow this dapp to view your public address', - connectSuccessfully: 'Connect successfully', + connectSuccessfully: 'Connection successful', supportedNetworks: 'Supported networks', - networkSupported: (networkNumber: number) => `${networkNumber} networks support`, + networkSupported: (networkNumber: number) => `${networkNumber} networks supported`, + failToDisconnect: 'Fail to disconnect', unableToFetchInformation: (validatorTitle: string) => `Unable to fetch ${validatorTitle} information`, }, filterOptions: { diff --git a/src/utils/i18n/vi_VN.ts b/src/utils/i18n/vi_VN.ts index 5dfe6d4d4..0c8bdd97b 100644 --- a/src/utils/i18n/vi_VN.ts +++ b/src/utils/i18n/vi_VN.ts @@ -191,9 +191,14 @@ export const vi = { provider: 'Provider', pools: 'Pool', nominate: 'Nominate', - evmNetworks: 'EVM networks', - substrateNetworks: 'Substrate networks', - networks: 'Networks', + evmNetworks: 'Mạng EVM', + substrateNetworks: 'Mạng Substrate', + networks: 'Mạng', + ledgerAccount: 'Tài khoản Ledger', + normalAccount: 'Tài khoản thường', + qrSignerAccount: 'Tài khoản QR signer', + watchOnlyAccount: 'Tài khoản chỉ xem', + unknownAccount: 'Tài khoản không xác định', }, title: { exportAccount: 'Xuất tài khoản ', @@ -381,10 +386,10 @@ export const vi = { unbond: 'Unstake', addContact: 'Thêm liên hệ', enableNetwork: 'Bật mạng', - newConnection: 'New connection', - disconnect: 'Disconnect', - applyAccounts: (account: number) => `Apply ${account} accounts`, - createOne: 'Create one', + newConnection: 'Kết nối mới', + disconnect: 'Ngắt kết nối', + applyAccounts: (account: number) => `Kết nối ${account} tài khoản`, + createOne: 'Tạo tài khoản', reload: 'Tải lại', }, inputLabel: { @@ -594,14 +599,15 @@ export const vi = { cannotGetBalance: 'Không thể lấy số dư', enableTokenOnChain: (tokenNames: string, chainName: string) => `Vui lòng bật ${tokenNames} trên ${chainName}`, disconnectModalMessage: - 'Once you disconnect, you will no longer see this connection on SubWallet and on your DApp.', - connectedNetworks: (chainLength: number) => `${chainLength} network(s)`, - connectedNetworkConnected: (chainLength: number) => `${chainLength} networks connected`, - connectedAccounts: (accountItemsLength: number) => `${accountItemsLength} account connected`, - connectWalletConnectMessage: 'By clicking "Connect", you allow this dapp to view your public address', - connectSuccessfully: 'Connect successfully', - supportedNetworks: 'Supported networks', - networkSupported: (networkNumber: number) => `${networkNumber} networks support`, + 'Khi ngắt kết nối, bạn sẽ không tìm thấy dApp trên SubWallet và dApp không còn kết nối với SubWallet', + connectedNetworks: (chainLength: number) => `${chainLength} mạng`, + connectedNetworkConnected: (chainLength: number) => `Đã kết nối ${chainLength} mạng`, + connectedAccounts: (accountItemsLength: number) => `${accountItemsLength} tài khoản đã kết nối`, + connectWalletConnectMessage: 'Bằng việc nhấp vào "Kết nối", bạn cho phép dapp xem địa chỉ public của tài khoản', + connectSuccessfully: 'Kết nối thành công', + supportedNetworks: 'Các mạng đã hỗ trợ', + networkSupported: (networkNumber: number) => `${networkNumber} mạng đã hỗ trợ`, + failToDisconnect: 'Ngắt kết nối thất bại', unableToFetchInformation: (validatorTitle: string) => `Không thể lấy thông tin của ${validatorTitle}`, }, filterOptions: { @@ -746,8 +752,8 @@ export const vi = { currentPassword: 'Mật khẩu hiện tại', newPassword: 'Mật khẩu mới', walletConnect: 'WalletConnect', - disconnect: 'Disconnect', - connectedNetworks: 'Connected networks', + disconnect: 'Ngắt kết nối', + connectedNetworks: 'Mạng đã kết nối', }, cryptoScreen: { receive: 'Địa chỉ', @@ -973,8 +979,8 @@ export const vi = { error: 'Lỗi', clearHistory: 'Xóa lịch sử', updateNetwork: 'Cập nhật mạng', - expiredConnectionTitle: 'Connection expired', - unsupportedNetworkTitle: 'Unsupported network', + expiredConnectionTitle: 'Kết nối đã quá hạn.', + unsupportedNetworkTitle: 'Mạng không được hỗ trợ', }, warningMessage: { passwordTooShort: 'Mật khẩu quá ngắn', @@ -1010,8 +1016,8 @@ export const vi = { tokenExists: 'Token đã tồn tại', enableNetworkMessage: 'Mạng bạn đã chọn chưa được kích hoạt. Vui lòng nhấp vào nút này để bật mạng hoặc chọn mạng khác', - expiredConnectionMessage: 'Connection expired. Please create a new connection from dApp', - unsupportedNetworkMessage: 'There is at least 1 chosen network unavailable', + expiredConnectionMessage: 'Kết nối đã quá hạn. Vui lòng kết nối lại với dApp', + unsupportedNetworkMessage: 'Có ít nhất 1 mạng đã chọn không khả dụng', }, errorMessage: { invalidPinCode: 'Mã PIN không hợp lệ', @@ -1067,8 +1073,8 @@ export const vi = { contactNameIsRequired: 'Tên liên hệ là bắt buộc', contactNameMustBeUnique: 'Tên liên hệ phải là duy nhất', invalidPassword: 'Mật khẩu không hợp lệ', - connectionAlreadyExist: 'Connection already exists', - failToAddConnection: 'Fail to add connection', + connectionAlreadyExist: 'Kết nối đã tồn tại', + failToAddConnection: 'Thêm kết nối thất bại', unreadableQrCode: 'Unreadable QR code. Please scan another one.', }, notificationMessage: { diff --git a/src/utils/i18n/zh_CN.ts b/src/utils/i18n/zh_CN.ts index 60a42dc0e..aea355b26 100644 --- a/src/utils/i18n/zh_CN.ts +++ b/src/utils/i18n/zh_CN.ts @@ -189,9 +189,14 @@ export const zh = { provider: '提供商', pools: '矿池', nominate: '提名', - evmNetworks: 'EVM networks', - substrateNetworks: 'Substrate networks', - networks: 'Networks', + evmNetworks: 'EVM网络', + substrateNetworks: 'Substrate网络', + networks: '网络', + ledgerAccount: 'Ledger账本账户', + normalAccount: '普通账户', + qrSignerAccount: '二维码登录的账户', + watchOnlyAccount: '仅观看账户', + unknownAccount: '未知账户', }, title: { exportAccount: '导出账户', @@ -377,10 +382,10 @@ export const zh = { unbond: '解除捆定', addContact: '添加联系人', enableNetwork: '启用网络', - newConnection: 'New connection', - disconnect: 'Disconnect', - applyAccounts: (account: number) => `Apply ${account} accounts`, - createOne: 'Create one', + newConnection: '新连接', + disconnect: '断开', + applyAccounts: (account: number) => `应用${account}账户`, + createOne: '创建', reload: '重新加载', }, inputLabel: { @@ -587,15 +592,15 @@ export const zh = { forgotPasswordMessage: '我们不保存你的密码。若你无法解锁账户,你将需要使用助记词以重置你的钱包。', cannotGetBalance: '无法获取余额', enableTokenOnChain: (tokenNames: string, chainName: string) => `请在 ${chainName}上启用 ${tokenNames}`, - disconnectModalMessage: - 'Once you disconnect, you will no longer see this connection on SubWallet and on your DApp.', - connectedNetworks: (chainLength: number) => `${chainLength} network(s)`, - connectedNetworkConnected: (chainLength: number) => `${chainLength} networks connected`, - connectedAccounts: (accountItemsLength: number) => `${accountItemsLength} account connected`, - connectWalletConnectMessage: 'By clicking "Connect", you allow this dapp to view your public address', - connectSuccessfully: 'Connect successfully', - supportedNetworks: 'Supported networks', - networkSupported: (networkNumber: number) => `${networkNumber} networks support`, + disconnectModalMessage: '一旦断开,你将不再在SubWallet及DApp看到该连接。', + connectedNetworks: (chainLength: number) => `${chainLength}网络`, + connectedNetworkConnected: (chainLength: number) => `已连接${chainLength}网络`, + connectedAccounts: (accountItemsLength: number) => `已连接${accountItemsLength}账户`, + connectWalletConnectMessage: '点击“连接”即表示你允许此dapp查看你的公共地址', + connectSuccessfully: '连接成功', + supportedNetworks: '已支持的网络', + networkSupported: (networkNumber: number) => `${networkNumber} 网络支持`, + failToDisconnect: '断开失败', unableToFetchInformation: (validatorTitle: string) => `无法获取${validatorTitle}资料`, }, filterOptions: { @@ -739,9 +744,9 @@ export const zh = { websiteAccessConfig: '网站访问配置', currentPassword: '当前密码', newPassword: '新密码', - walletConnect: 'WalletConnect', - disconnect: 'Disconnect', - connectedNetworks: 'Connected networks', + walletConnect: '连接钱包', + disconnect: '断开', + connectedNetworks: '已连接网络', }, cryptoScreen: { receive: '地址', @@ -964,8 +969,8 @@ export const zh = { error: '出错!', clearHistory: '清档记录', updateNetwork: '更新网络', - expiredConnectionTitle: 'Connection expired', - unsupportedNetworkTitle: 'Unsupported network', + expiredConnectionTitle: '连接已过期', + unsupportedNetworkTitle: '未支持的网络', }, warningMessage: { passwordTooShort: '密码过短', @@ -996,8 +1001,8 @@ export const zh = { featureIsNotAvailable: '此功能不适用于所选的账户', tokenExists: '此通证已存在', enableNetworkMessage: '你选择的网络尚未启用。 请点击此按钮启用或选择其他网络', - expiredConnectionMessage: 'Connection expired. Please create a new connection from dApp', - unsupportedNetworkMessage: 'There is at least 1 chosen network unavailable', + expiredConnectionMessage: '连接已过期。请从dApp创建新连接', + unsupportedNetworkMessage: '至少有1项已选的网络不可用', }, errorMessage: { invalidPinCode: 'PIN码无效', @@ -1051,8 +1056,8 @@ export const zh = { contactNameIsRequired: '联系名字为必填项', contactNameMustBeUnique: '联系名字必须是唯一的', invalidPassword: '密码无效', - connectionAlreadyExist: 'Connection already exists', - failToAddConnection: 'Fail to add connection', + connectionAlreadyExist: '连接已存在', + failToAddConnection: '添加连接失败', unreadableQrCode: 'Unreadable QR code. Please scan another one.', }, notificationMessage: {