Skip to content

Commit

Permalink
[Issue-973]: Support multi-language for WalletConnect feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dominhquang committed Aug 26, 2023
1 parent 7d3460b commit 1502ace
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 72 deletions.
13 changes: 7 additions & 6 deletions src/hooks/account/useGetAccountTitleByAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
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);

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]);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const ConnectWalletConnectConfirmation = ({ request }: Props) => {
const { isDeepLinkConnect } = useSelector((state: RootState) => state.settings);
const nameSpaceNameMap = useMemo(
(): Record<string, string> => ({
[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,
}),
[],
);
Expand Down Expand Up @@ -177,7 +177,7 @@ export const ConnectWalletConnectConfirmation = ({ request }: Props) => {
</>
)}
{isSupportCase && (
<View>
<View style={{ gap: theme.padding }}>
{Object.entries(namespaceAccounts).map(([namespace, value]) => {
const { appliedAccounts, availableAccounts, networks, selectedAccounts } = value;

Expand Down
2 changes: 1 addition & 1 deletion src/screens/Settings/WalletConnect/ConnectionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/screens/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
<BackgroundIcon
shape={'circle'}
backgroundColor={setting.backgroundColor}
customIcon={<SVGImages.WalletConnect width={16} height={16} color={theme.colorWhite} />}
/>
) : undefined
}
icon={setting.icon}
backgroundColor={setting.backgroundColor}
onPress={setting.onPress}
Expand All @@ -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 ? (
<BackgroundIcon
shape={'circle'}
backgroundColor={setting.backgroundColor}
customIcon={<SVGImages.WalletConnect width={16} height={16} color={theme.colorWhite} />}
/>
) : undefined
}
icon={setting.icon}
backgroundColor={setting.backgroundColor}
onPress={setting.onPress}
Expand Down
6 changes: 3 additions & 3 deletions src/screens/Transaction/SendFundV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ export const SendFund = ({
render={({ field: { value, ref, onChange, onBlur } }) => (
<InputAddress
ref={ref}
label={'Send to'}
label={i18n.inputLabel.sendTo}
value={value}
onChangeText={onChange}
onBlur={onBlur}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ export const SendFund = ({
}
});
}}>
Next
{i18n.buttonTitles.next}
</Button>
)}
{viewStep === 2 && (
Expand Down Expand Up @@ -1042,7 +1042,7 @@ export const SendFund = ({
}
}}
style={stylesheet.max}>
{<Typography.Text style={stylesheet.maxText}>Max</Typography.Text>}
{<Typography.Text style={stylesheet.maxText}>{i18n.common.max}</Typography.Text>}
</TouchableOpacity>
)}
</View>
Expand Down
10 changes: 8 additions & 2 deletions src/utils/i18n/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down
52 changes: 29 additions & 23 deletions src/utils/i18n/vi_VN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ',
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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ỉ',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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ệ',
Expand Down Expand Up @@ -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: {
Expand Down
55 changes: 30 additions & 25 deletions src/utils/i18n/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '导出账户',
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -739,9 +744,9 @@ export const zh = {
websiteAccessConfig: '网站访问配置',
currentPassword: '当前密码',
newPassword: '新密码',
walletConnect: 'WalletConnect',
disconnect: 'Disconnect',
connectedNetworks: 'Connected networks',
walletConnect: '连接钱包',
disconnect: '断开',
connectedNetworks: '已连接网络',
},
cryptoScreen: {
receive: '地址',
Expand Down Expand Up @@ -964,8 +969,8 @@ export const zh = {
error: '出错!',
clearHistory: '清档记录',
updateNetwork: '更新网络',
expiredConnectionTitle: 'Connection expired',
unsupportedNetworkTitle: 'Unsupported network',
expiredConnectionTitle: '连接已过期',
unsupportedNetworkTitle: '未支持的网络',
},
warningMessage: {
passwordTooShort: '密码过短',
Expand Down Expand Up @@ -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码无效',
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 1502ace

Please sign in to comment.