Skip to content

Commit

Permalink
add fallback value to i18n and fix inconsistent probelm (#166)
Browse files Browse the repository at this point in the history
* feat: add i18n fallback txt & useNamespace hooks

Signed-off-by: warjiang <[email protected]>

* fix: inconsistent translation

Signed-off-by: warjiang <[email protected]>

---------

Signed-off-by: warjiang <[email protected]>
  • Loading branch information
warjiang authored Jan 15, 2025
1 parent 46b8a29 commit 466dd4d
Show file tree
Hide file tree
Showing 24 changed files with 697 additions and 387 deletions.
48 changes: 35 additions & 13 deletions ui/apps/dashboard/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"3fea7ca76cdece641436d7ab0d02ab1b": "state",
"d679aea3aae1201e38c4baaaeef86efe": "Running",
"903b25f64e1c0d9b7f56ed80c256a2e7": "Unknown state",
"eca37cb0726c51702f70c486c1c38cf3": "Creation time",
"a0d6cb39b547d45a530a3308dce79c86": "Work cluster information",
"6860e13ac48e930f8076ebfe37176b78": "Number of nodes:",
"a1dacced95ddca3603110bdb1ae46af1": "CPU usage:",
"5eaa09de6e55b322fcc299f641d73ce7": "Memory usage:",
"820c4003e23553b3124f1608916d5282": "Pod allocation situation:",
"eca37cb0726c51702f70c486c1c38cf3": "creation time",
"a0d6cb39b547d45a530a3308dce79c86": "member cluster information",
"6860e13ac48e930f8076ebfe37176b78": "Number of nodes",
"a1dacced95ddca3603110bdb1ae46af1": "CPU usage",
"5eaa09de6e55b322fcc299f641d73ce7": "Memory usage",
"820c4003e23553b3124f1608916d5282": "Pod allocation situation",
"85c6051762df2fe8f93ebc1083b7f6a4": "Strategy information",
"612af712ef5ed7868a6b2f1d3d68530c": "Multi cloud resource information",
"1200778cf86309309154ef88804fa22e": "Multi cloud namespace",
Expand Down Expand Up @@ -62,12 +62,13 @@
"8a99082b2c32c843d2241e0ba60a3619": "Distribution strategy",
"eaf8a02d1b16fcf94302927094af921f": "Coverage strategy",
"2b6bc0f293f5ca01b006206c2535ccbc": "operation",
"607e7a4f377fa66b0b28ce318aab841f": "see",
"607e7a4f377fa66b0b28ce318aab841f": "view",
"e83a256e4f5bb4ff8b3d804b5473217a": "confirm",
"2f4aaddde33c9b93c36fd2503f3d122b": "delete",
"280c56077360c204e536eb770495bc5f": "Namespaces:",
"280c56077360c204e536eb770495bc5f": "Namespaces",
"cfaff3e369b9bd51504feb59bf0972a0": "Search by namespace",
"96d6b0fcc58b6f65dc4c00c6138d2ac0": "Add workload",
"634a943c97e905149acb81cef5bda28e": "Edit workload",
"8347a927c09a4ec2fe473b0a93f667d0": "modify",
"ac2f01145a5c4a9aaaf2f828650d91a3": "Add a new namespace",
"e0a23c19b8a0044c5defd167b441d643": "${name} 'is a required field",
Expand All @@ -76,7 +77,7 @@
"d41f6609ddbfa15fb95074a463f3b71a": "Do you want to skip automatic distribution",
"0a60ac8f02ccd2cf723f927284877851": "yes",
"c9744f45e76d885ae1c74d4f4a934b2e": "no",
"1d5fc011c19d35d08186afc4bad14be9": "Do you want to skip automatic scheduling",
"1d5fc011c19d35d08186afc4bad14be9": "Skip automatic scheduling",
"e4b51d5cd0e4f199e41c25be1c7591d3": "running state ",
"919994bf077d49f68f016811ffb5600e": "Successfully deleted namespace",
"9cdd00dbaa024d64a8b8134ae57974a6": "Delete namespace failed",
Expand Down Expand Up @@ -128,6 +129,7 @@
"03743b3522b7d69da1cdc44d7418ce4d": "An error occurred, please refresh and try again",
"fc763fd5ddf637fe4ba1ac59e10b8d3a": "Confirm to delete",
"627ce40030fcda39210cca054bb77775": "Is it a workload",
"7cd82aa99087de6a052b1aba33dbd3ed": "Is it a service",
"330363dfc524cff2488f2ebde0500896": "success",
"acd5cb847a4aff235c9a01ddeb6f9770": "fail",
"f8484c9d3de78566f9e255360977f12c": "Failed to delete configuration",
Expand All @@ -143,7 +145,7 @@
"944bfddeffc83e54cc6920f281d9b9f3": "Is it configured",
"b2af3f316129c869a96f9099262df175": "View configuration",
"5117bc6c603b6ceb9ee5197e30432266": "Edit configuration",
"6d95c8c1f41302ab4bc28e08a1226c8c": "Configuration type",
"6d95c8c1f41302ab4bc28e08a1226c8c": "Configuration Type",
"f05bc327e4066ca97af893e52e2c62b3": "Strategy Details",
"aa141bcb65729912b79cb27995a8989b": "Scheduling strategy",
"8233550b23ab7acc2a9c3b2623c371dd": "Successfully added scheduling strategy",
Expand All @@ -152,6 +154,26 @@
"5863fd1d291adf46d804f5801a79d0e1": "Editing scheduling strategy failed",
"79d5c80e3be24682145aa9246df18b40": "Is it a cluster?",
"85fe5099f6807dada65d274810933389": "Cluster",
"c7961c290ec86485d8692f3c09b4075b": "New services added",
"8f3747c057d893862fbe4b7980e9b451": "Service Name"
}
"c7961c290ec86485d8692f3c09b4075b": "Add service",
"cc51f34aa418cb3a596fd6470c677bfe": "Edit service",
"8f3747c057d893862fbe4b7980e9b451": "Service Name",
"b13c676134d8ab066d62e9ea5bdf796c": "Do you want to delete {{name}} propagationpolicy?",
"30ee910e8ea18311b1b2efbea94333b8": "Do you want to delete {{name}} cluster?",
"fb09e53e96ff76a72894a816dd7c731c": "Cluster {{name}} deleted successfully",
"dd7454e05ce9088395dbeb92bf939fd4": "Do you want to delete {{name}} secret?",
"af57bb34df71db6c4a115ed7665faf5d": "Do you want to delete {{name}} configmap?",
"0518f7eb54d49436d72ae539f422e68b": "Edit {{name}} propagationpolicy",
"0a3e7cdadc44fb133265152268761abc": "Workload Type",
"924f67de61fc9e07fff979306900dc6a": "Service Type",
"88270824e97355ca21f4101e5f1b73a0": "Search by name, press enter to start searching",
"8a59b316f11d99f01ebe9b1b466ba8de": "Differentiation strategy type",
"7c7e4becc6e9b2be2a196ed506cdc518": "Add differentiation strategy",
"d4e6e1153ed42d2b2482f22ee04ac05a": "Add cluster differentiation strategy",
"f0ade52acfa0bc5bd63e7cb29db84959": "Do you want to delete {{name}} workload?",
"6163856192e115e6b914d6fb8c4fd82c": "Do you want to delete {{name}} service?",
"ad23e7bbdbe6ed03eebfc27eef7570fa": "View service",
"7afddf70e5c82fab8fa935458b53174a": "Add differentiation strategy",
"236513393327bd6b098056314f8676ac": "Edit differentiation strategy",
"781a90424b3d02153bc979e0f90179aa": "{{name}} detail",
"1af8d577b89a4caf0e4b30734bbf7143": "Do you want to delete {{name}} differentiation strategy?"
}
36 changes: 29 additions & 7 deletions ui/apps/dashboard/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"903b25f64e1c0d9b7f56ed80c256a2e7": "未知状态",
"eca37cb0726c51702f70c486c1c38cf3": "创建时间",
"a0d6cb39b547d45a530a3308dce79c86": "工作集群信息",
"6860e13ac48e930f8076ebfe37176b78": "节点数量",
"a1dacced95ddca3603110bdb1ae46af1": "CPU使用情况",
"5eaa09de6e55b322fcc299f641d73ce7": "Memory使用情况",
"820c4003e23553b3124f1608916d5282": "Pod分配情况",
"6860e13ac48e930f8076ebfe37176b78": "节点数量",
"a1dacced95ddca3603110bdb1ae46af1": "CPU使用情况",
"5eaa09de6e55b322fcc299f641d73ce7": "Memory使用情况",
"820c4003e23553b3124f1608916d5282": "Pod分配情况",
"85c6051762df2fe8f93ebc1083b7f6a4": "策略信息",
"612af712ef5ed7868a6b2f1d3d68530c": "多云资源信息",
"1200778cf86309309154ef88804fa22e": "多云命名空间",
Expand Down Expand Up @@ -64,9 +64,10 @@
"607e7a4f377fa66b0b28ce318aab841f": "查看",
"e83a256e4f5bb4ff8b3d804b5473217a": "确认",
"2f4aaddde33c9b93c36fd2503f3d122b": "删除",
"280c56077360c204e536eb770495bc5f": "命名空间",
"280c56077360c204e536eb770495bc5f": "命名空间",
"cfaff3e369b9bd51504feb59bf0972a0": "按命名空间搜索",
"96d6b0fcc58b6f65dc4c00c6138d2ac0": "新增工作负载",
"634a943c97e905149acb81cef5bda28e": "编辑工作负载",
"8347a927c09a4ec2fe473b0a93f667d0": "修改",
"ac2f01145a5c4a9aaaf2f828650d91a3": "新增命名空间",
"e0a23c19b8a0044c5defd167b441d643": "'${name}' 是必选字段",
Expand Down Expand Up @@ -127,6 +128,7 @@
"03743b3522b7d69da1cdc44d7418ce4d": "发生错误,请刷新后重试",
"fc763fd5ddf637fe4ba1ac59e10b8d3a": "确认要删除",
"627ce40030fcda39210cca054bb77775": "工作负载么",
"7cd82aa99087de6a052b1aba33dbd3ed": "服务么",
"330363dfc524cff2488f2ebde0500896": "成功",
"acd5cb847a4aff235c9a01ddeb6f9770": "失败",
"f8484c9d3de78566f9e255360977f12c": "删除配置失败",
Expand All @@ -152,5 +154,25 @@
"79d5c80e3be24682145aa9246df18b40": "集群么?",
"85fe5099f6807dada65d274810933389": "集群",
"c7961c290ec86485d8692f3c09b4075b": "新增服务",
"8f3747c057d893862fbe4b7980e9b451": "服务名称"
}
"cc51f34aa418cb3a596fd6470c677bfe": "编辑服务",
"8f3747c057d893862fbe4b7980e9b451": "服务名称",
"b13c676134d8ab066d62e9ea5bdf796c": "要删除{{name}}调度策略么?",
"30ee910e8ea18311b1b2efbea94333b8": "要删除{{name}}集群么?",
"fb09e53e96ff76a72894a816dd7c731c": "集群{{name}}删除成功",
"dd7454e05ce9088395dbeb92bf939fd4": "要删除{{name}}秘钥么?",
"af57bb34df71db6c4a115ed7665faf5d": "要删除{{name}}配置么?",
"0518f7eb54d49436d72ae539f422e68b": "编辑{{name}}调度策略",
"0a3e7cdadc44fb133265152268761abc": "工作负载类型",
"924f67de61fc9e07fff979306900dc6a": "服务类型",
"88270824e97355ca21f4101e5f1b73a0": "按名称检索,按下回车开始搜索",
"8a59b316f11d99f01ebe9b1b466ba8de": "差异化策略类型",
"7c7e4becc6e9b2be2a196ed506cdc518": "新增差异化策略",
"d4e6e1153ed42d2b2482f22ee04ac05a": "新增集群差异化策略",
"f0ade52acfa0bc5bd63e7cb29db84959": "确认要删除 {{name}} 工作负载么?",
"6163856192e115e6b914d6fb8c4fd82c": "确认要删除 {{name}} 服务么",
"ad23e7bbdbe6ed03eebfc27eef7570fa": "查看服务",
"7afddf70e5c82fab8fa935458b53174a": "新增覆盖策略",
"236513393327bd6b098056314f8676ac": "编辑覆盖策略",
"781a90424b3d02153bc979e0f90179aa": "{{name}} 策略详情",
"1af8d577b89a4caf0e4b30734bbf7143": "确认要删除 {{name}} 覆盖策略么"
}
75 changes: 53 additions & 22 deletions ui/apps/dashboard/src/pages/cluster-manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const ClusterManagePage = () => {
});
const columns: TableColumnProps<Cluster>[] = [
{
title: i18nInstance.t('c3f28b34bbdec501802fa403584267e6'),
title: i18nInstance.t('c3f28b34bbdec501802fa403584267e6', '集群名称'),
key: 'clusterName',
width: 150,
render: (_, r) => {
Expand All @@ -63,14 +63,17 @@ const ClusterManagePage = () => {
},
},
{
title: i18nInstance.t('bd17297989ec345cbc03ae0b8a13dc0a'),
title: i18nInstance.t(
'bd17297989ec345cbc03ae0b8a13dc0a',
'kubernetes版本',
),
dataIndex: 'kubernetesVersion',
key: 'kubernetesVersion',
width: 150,
align: 'center',
},
{
title: i18nInstance.t('ee00813361387a116d274c608ba8bb13'),
title: i18nInstance.t('ee00813361387a116d274c608ba8bb13', '集群状态'),
dataIndex: 'ready',
key: 'ready',
align: 'center',
Expand Down Expand Up @@ -110,7 +113,7 @@ const ClusterManagePage = () => {
},
},
{
title: i18nInstance.t('f0789e79d48f135e5d870753f7a85d05'),
title: i18nInstance.t('f0789e79d48f135e5d870753f7a85d05', '模式'),
dataIndex: 'syncMode',
width: 150,
align: 'center',
Expand All @@ -123,7 +126,7 @@ const ClusterManagePage = () => {
},
},
{
title: i18nInstance.t('b86224e030e5948f96b70a4c3600b33f'),
title: i18nInstance.t('b86224e030e5948f96b70a4c3600b33f', '节点状态'),
dataIndex: 'nodeStatus',
align: 'center',
width: 150,
Expand All @@ -140,7 +143,7 @@ const ClusterManagePage = () => {
},
},
{
title: i18nInstance.t('763a78a5fc84dbca6f0137a591587f5f'),
title: i18nInstance.t('763a78a5fc84dbca6f0137a591587f5f', 'cpu用量'),
dataIndex: 'cpuFraction',
width: '15%',
render: (_, r) => {
Expand All @@ -156,7 +159,7 @@ const ClusterManagePage = () => {
},
},
{
title: i18nInstance.t('8b2e672e8b847415a47cc2dd25a87a07'),
title: i18nInstance.t('8b2e672e8b847415a47cc2dd25a87a07', 'memory用量'),
dataIndex: 'memoryFraction',
width: '15%',
render: (_, r) => {
Expand All @@ -172,14 +175,14 @@ const ClusterManagePage = () => {
},
},
{
title: i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc'),
title: i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
key: 'op',
width: 200,
render: (_, r) => {
return (
<Space.Compact>
<Button size={'small'} type="link" disabled>
{i18nInstance.t('607e7a4f377fa66b0b28ce318aab841f')}
{i18nInstance.t('607e7a4f377fa66b0b28ce318aab841f', '查看')}
</Button>
<Button
size={'small'}
Expand All @@ -193,29 +196,42 @@ const ClusterManagePage = () => {
});
}}
>
{i18nInstance.t('95b351c86267f3aedf89520959bce689')}
{i18nInstance.t('95b351c86267f3aedf89520959bce689', '编辑')}
</Button>
<Popconfirm
placement="topRight"
title={`${i18nInstance.t('fc763fd5ddf637fe4ba1ac59e10b8d3a', '确认要删除')}${r.objectMeta.name}${i18nInstance.t('79d5c80e3be24682145aa9246df18b40', '集群么?')}`}
title={i18nInstance.t('30ee910e8ea18311b1b2efbea94333b8', {
name: r.objectMeta.name,
})}
onConfirm={async () => {
const ret = await DeleteCluster(r.objectMeta.name);
if (ret.code === 200) {
await messageApi.success(
`${i18nInstance.t('85fe5099f6807dada65d274810933389', '集群')}${r.objectMeta.name}${i18nInstance.t('0007d170de017dafc266aa03926d7f00', '删除成功')}`,
i18nInstance.t('fb09e53e96ff76a72894a816dd7c731c', {
name: r.objectMeta.name,
}),
);
await refetch();
} else {
await messageApi.error(
i18nInstance.t('9e7856e9c5938b9200dbdc174e97cf8a'),
i18nInstance.t(
'9e7856e9c5938b9200dbdc174e97cf8a',
'集群删除失败',
),
);
}
}}
okText={i18nInstance.t('e83a256e4f5bb4ff8b3d804b5473217a')}
cancelText={i18nInstance.t('625fb26b4b3340f7872b411f401e754c')}
okText={i18nInstance.t(
'e83a256e4f5bb4ff8b3d804b5473217a',
'确认',
)}
cancelText={i18nInstance.t(
'625fb26b4b3340f7872b411f401e754c',
'取消',
)}
>
<Button size={'small'} type="link" danger>
{i18nInstance.t('2f4aaddde33c9b93c36fd2503f3d122b')}
{i18nInstance.t('2f4aaddde33c9b93c36fd2503f3d122b', '删除')}
</Button>
</Popconfirm>
</Space.Compact>
Expand All @@ -227,7 +243,10 @@ const ClusterManagePage = () => {
<Panel>
<div className={'flex flex-row justify-between mb-4'}>
<Input.Search
placeholder={i18nInstance.t('e8d235e76b8e310660e158dc4c2fd560')}
placeholder={i18nInstance.t(
'e8d235e76b8e310660e158dc4c2fd560',
'按集群名称搜索',
)}
className={'w-[400px]'}
/>
<Button
Expand All @@ -241,7 +260,7 @@ const ClusterManagePage = () => {
});
}}
>
{i18nInstance.t('4cd980b26c5c76cdd4a5c5e44064d6da')}
{i18nInstance.t('4cd980b26c5c76cdd4a5c5e44064d6da', '新增集群')}
</Button>
</div>
<Table
Expand All @@ -258,11 +277,17 @@ const ClusterManagePage = () => {
if (ret.code === 200) {
if (clusterModalData.mode === 'create') {
await messageApi.success(
i18nInstance.t('dca2754f7a646ef40f495f75145428d0'),
i18nInstance.t(
'dca2754f7a646ef40f495f75145428d0',
'集群接入成功',
),
);
} else if (clusterModalData.mode === 'edit') {
await messageApi.success(
i18nInstance.t('474162cdce4e540d3a4d97c6de92cd68'),
i18nInstance.t(
'474162cdce4e540d3a4d97c6de92cd68',
'集群更新成功',
),
);
}
await refetch();
Expand All @@ -274,11 +299,17 @@ const ClusterManagePage = () => {
} else {
if (clusterModalData.mode === 'create') {
await messageApi.error(
i18nInstance.t('3b0b5df2e18ef97b7f948c60906a7821'),
i18nInstance.t(
'3b0b5df2e18ef97b7f948c60906a7821',
'集群接入失败',
),
);
} else if (clusterModalData.mode === 'edit') {
await messageApi.error(
i18nInstance.t('01812e386ab69ce4391769918e32d6d1'),
i18nInstance.t(
'01812e386ab69ce4391769918e32d6d1',
'集群更新失败',
),
);
}
}
Expand Down
Loading

0 comments on commit 466dd4d

Please sign in to comment.