@@ -123,68 +134,76 @@ const Overview = () => {
const resourceItems: DescriptionsProps['items'] = [
{
key: 'policy-info',
- label: i18nInstance.t('85c6051762df2fe8f93ebc1083b7f6a4', '策略信息'),
+ label: titleCase(
+ i18nInstance.t('85c6051762df2fe8f93ebc1083b7f6a4', '策略信息'),
+ ),
children: (
),
-
span: 3,
},
{
key: 'multicloud-resources-info',
- label: i18nInstance.t('612af712ef5ed7868a6b2f1d3d68530c', '多云资源信息'),
+ label: titleCase(
+ i18nInstance.t('612af712ef5ed7868a6b2f1d3d68530c', '多云资源信息'),
+ ),
children: (
),
-
span: 3,
},
];
@@ -194,17 +213,23 @@ const Overview = () => {
diff --git a/ui/apps/dashboard/src/routes/route.tsx b/ui/apps/dashboard/src/routes/route.tsx
index 1982504f..423b0ece 100644
--- a/ui/apps/dashboard/src/routes/route.tsx
+++ b/ui/apps/dashboard/src/routes/route.tsx
@@ -1,4 +1,4 @@
-import i18nInstance from '@/utils/i18n';
+import i18nInstance, { titleCase } from '@/utils/i18n';
import React, { ReactNode } from 'react';
import { NonIndexRouteObject, redirect } from 'react-router-dom';
import type { MenuProps } from 'antd';
@@ -69,7 +69,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'OVERVIEW',
- sidebarName: i18nInstance.t('86385379cf9cfbc2c554944f1c054a45'),
+ sidebarName: titleCase(
+ i18nInstance.t('86385379cf9cfbc2c554944f1c054a45'),
+ ),
icon:
,
},
},
@@ -77,7 +79,9 @@ export function getRoutes() {
path: '/multicloud-resource-manage',
handle: {
sidebarKey: 'MULTICLOUD-RESOURCE-MANAGE',
- sidebarName: i18nInstance.t('21a4e07b08a4efbbfe2b9d88c208836a'),
+ sidebarName: titleCase(
+ i18nInstance.t('21a4e07b08a4efbbfe2b9d88c208836a'),
+ ),
isPage: false,
icon:
,
},
@@ -87,9 +91,11 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'NAMESPACE',
- sidebarName: i18nInstance.t(
- 'a4b28a416f0b6f3c215c51e79e517298',
- '命名空间',
+ sidebarName: titleCase(
+ i18nInstance.t(
+ 'a4b28a416f0b6f3c215c51e79e517298',
+ '命名空间',
+ ),
),
},
},
@@ -98,7 +104,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'WORKLOAD',
- sidebarName: i18nInstance.t('c3bc562e9ffcae6029db730fe218515c'),
+ sidebarName: titleCase(
+ i18nInstance.t('c3bc562e9ffcae6029db730fe218515c'),
+ ),
},
},
{
@@ -106,7 +114,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'SERVICE',
- sidebarName: i18nInstance.t('4653569c7943335f62caa11e38d48aa0'),
+ sidebarName: titleCase(
+ i18nInstance.t('4653569c7943335f62caa11e38d48aa0'),
+ ),
},
},
{
@@ -114,7 +124,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'CONFIG',
- sidebarName: i18nInstance.t('837d8a6473195b8b5e85d58a72cb9c7e'),
+ sidebarName: titleCase(
+ i18nInstance.t('837d8a6473195b8b5e85d58a72cb9c7e'),
+ ),
},
},
],
@@ -123,7 +135,9 @@ export function getRoutes() {
path: '/multicloud-policy-manage',
handle: {
sidebarKey: 'MULTICLOUD-POLICY-MANAGE',
- sidebarName: i18nInstance.t('8654db688fcb1f7f11f6d7ea6b208a55'),
+ sidebarName: titleCase(
+ i18nInstance.t('8654db688fcb1f7f11f6d7ea6b208a55'),
+ ),
icon:
,
isPage: false,
},
@@ -133,7 +147,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'PROPAGATION-POLICY',
- sidebarName: i18nInstance.t('a95abe7b8eeb55427547e764bf39f1c4'),
+ sidebarName: titleCase(
+ i18nInstance.t('a95abe7b8eeb55427547e764bf39f1c4'),
+ ),
},
},
{
@@ -141,7 +157,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'OVERRIDE-POLICY',
- sidebarName: i18nInstance.t('0a7e9443c41575378d2db1e288d3f1cb'),
+ sidebarName: titleCase(
+ i18nInstance.t('0a7e9443c41575378d2db1e288d3f1cb'),
+ ),
},
},
],
@@ -151,7 +169,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'CLUSTER-MANAGE',
- sidebarName: i18nInstance.t('74ea72bbd64d8251bbc2642cc38e7bb1'),
+ sidebarName: titleCase(
+ i18nInstance.t('74ea72bbd64d8251bbc2642cc38e7bb1'),
+ ),
icon:
,
isPage: false,
},
@@ -160,7 +180,9 @@ export function getRoutes() {
path: '/basic-config',
handle: {
sidebarKey: 'BASIC-CONFIG',
- sidebarName: i18nInstance.t('cba0d61936703636d3ab45914c9e754a'),
+ sidebarName: titleCase(
+ i18nInstance.t('cba0d61936703636d3ab45914c9e754a'),
+ ),
icon:
,
isPage: false,
},
@@ -170,7 +192,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'OEM',
- sidebarName: i18nInstance.t('bdf0eb5121c6dd3b2c57ab9d01b02a7e'),
+ sidebarName: titleCase(
+ i18nInstance.t('bdf0eb5121c6dd3b2c57ab9d01b02a7e'),
+ ),
},
},
{
@@ -178,7 +202,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'UPGRADE',
- sidebarName: i18nInstance.t('0506797675615f94ddf57bebca9da81f'),
+ sidebarName: titleCase(
+ i18nInstance.t('0506797675615f94ddf57bebca9da81f'),
+ ),
},
},
{
@@ -186,7 +212,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'KARMADA-CONFIG',
- sidebarName: i18nInstance.t('3955f4df8c2b4cb52d3c91296308edef'),
+ sidebarName: titleCase(
+ i18nInstance.t('3955f4df8c2b4cb52d3c91296308edef'),
+ ),
},
},
{
@@ -194,7 +222,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'HELM',
- sidebarName: i18nInstance.t('f8bb304d7eae5ddba6ac13bf6931187b'),
+ sidebarName: titleCase(
+ i18nInstance.t('f8bb304d7eae5ddba6ac13bf6931187b'),
+ ),
},
},
{
@@ -202,7 +232,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'REGISTRY',
- sidebarName: i18nInstance.t('c8330a63d6dfbb7dabb24cbf26430cb4'),
+ sidebarName: titleCase(
+ i18nInstance.t('c8330a63d6dfbb7dabb24cbf26430cb4'),
+ ),
},
},
],
@@ -211,9 +243,8 @@ export function getRoutes() {
path: '/advanced-config',
handle: {
sidebarKey: 'ADVANCED-CONFIG',
- sidebarName: i18nInstance.t(
- '1f318234cab713b51b5172d91770bc11',
- '高级配置',
+ sidebarName: titleCase(
+ i18nInstance.t('1f318234cab713b51b5172d91770bc11', '高级配置'),
),
icon:
,
isPage: false,
@@ -224,7 +255,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'FAILOVER',
- sidebarName: i18nInstance.t('41c84a00fe4f8f03d3f06a5887de31c8'),
+ sidebarName: titleCase(
+ i18nInstance.t('41c84a00fe4f8f03d3f06a5887de31c8'),
+ ),
},
},
{
@@ -232,7 +265,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'RESCHEDULE',
- sidebarName: i18nInstance.t('28a905999d14769b2aae998b74c1a864'),
+ sidebarName: titleCase(
+ i18nInstance.t('28a905999d14769b2aae998b74c1a864'),
+ ),
},
},
{
@@ -240,7 +275,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'PERMISSION',
- sidebarName: i18nInstance.t('23bbdd59d0b1d94621fc98e7f533ad9f'),
+ sidebarName: titleCase(
+ i18nInstance.t('23bbdd59d0b1d94621fc98e7f533ad9f'),
+ ),
},
},
],
@@ -249,7 +286,9 @@ export function getRoutes() {
path: '/addon',
handle: {
sidebarKey: 'ADDON',
- sidebarName: i18nInstance.t('14c4e4ecdac2ff3337385747dda6e621'),
+ sidebarName: titleCase(
+ i18nInstance.t('14c4e4ecdac2ff3337385747dda6e621'),
+ ),
icon:
,
isPage: false,
},
@@ -259,7 +298,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'BUILDIN',
- sidebarName: i18nInstance.t('976eb1e050088fbdd7d2cab3f644e7e5'),
+ sidebarName: titleCase(
+ i18nInstance.t('976eb1e050088fbdd7d2cab3f644e7e5'),
+ ),
},
},
{
@@ -267,7 +308,9 @@ export function getRoutes() {
element:
,
handle: {
sidebarKey: 'THIRDPARTY',
- sidebarName: i18nInstance.t('fb7f97d757a27c46d1e4f03287d9dd1f'),
+ sidebarName: titleCase(
+ i18nInstance.t('fb7f97d757a27c46d1e4f03287d9dd1f'),
+ ),
},
},
],
diff --git a/ui/apps/dashboard/src/utils/i18n.tsx b/ui/apps/dashboard/src/utils/i18n.tsx
index 0b12fec8..58bb1505 100644
--- a/ui/apps/dashboard/src/utils/i18n.tsx
+++ b/ui/apps/dashboard/src/utils/i18n.tsx
@@ -58,4 +58,22 @@ export function getSidebarWidth(lang?: string) {
return supportedLangConfig[lang]?.sidebarWidth || '';
}
+export function capitalize(value: string) {
+ if (!value) return '';
+ return value.charAt(0).toUpperCase() + value.slice(1);
+}
+
+export function titleCase(value: string) {
+ if (!value) return '';
+ return value
+ .split(' ')
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(' ');
+}
+
+export function lowerCase(value: string) {
+ if (!value) return '';
+ return value.toLowerCase();
+}
+
export default i18nInstance;