From 31d7637d679c7d97576e2f6ecc597f5eee8dc92c Mon Sep 17 00:00:00 2001 From: Unitwk Date: Mon, 2 Sep 2024 17:29:26 +0800 Subject: [PATCH] feat: i18n code --- frontend/src/components/fc/TagsDialog.vue | 16 ++++++++-------- frontend/src/widgets/InstanceList.vue | 2 +- frontend/src/widgets/instance/Shortcut.vue | 14 +++++++------- languages/en_US.json | 17 ++++++++++++++++- languages/zh_CN.json | 17 ++++++++++++++++- .../src/app/routers/instance_operate_router.ts | 4 ++-- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/fc/TagsDialog.vue b/frontend/src/components/fc/TagsDialog.vue index e625adf8..f06e2180 100644 --- a/frontend/src/components/fc/TagsDialog.vue +++ b/frontend/src/components/fc/TagsDialog.vue @@ -55,7 +55,7 @@ const cancel = async () => { const submit = async () => { try { await saveTags(); - message.success(t("保存成功")); + message.success(t("TXT_CODE_a7907771")); await cancel(); } catch (error) { reportErrorMsg(error); @@ -76,7 +76,7 @@ defineExpose({ openDialog }); {{ t( - "实例拥有标签之后,MCSManager 在显示这些实例时,将自动按照标签名字对实例进行分类供用户筛选,标签名字支持任何语言。" + "TXT_CODE_f84ae54f" ) }} @@ -96,12 +96,12 @@ defineExpose({ openDialog });
- {{ t("此实例的标签列表") }} + {{ t("TXT_CODE_2c1337d") }} - {{ t("请勿创建过多新标签,这可能会导致界面上元素混乱和面板性能下降。") }} + {{ t("TXT_CODE_e26d53d5") }}
@@ -128,7 +128,7 @@ defineExpose({ openDialog }); /> - {{ t("新标签") }} + {{ t("TXT_CODE_3dd66d98") }}
@@ -136,14 +136,14 @@ defineExpose({ openDialog });
- {{ t("部分可选标签") }} + {{ t("TXT_CODE_67d1ea21") }} {{ t( - "这些可选择的标签由当前页实例列表计算而来,并不包含所有已存在的标签,此处最多展示 30 个" + "TXT_CODE_3ecee271" ) }} diff --git a/frontend/src/widgets/InstanceList.vue b/frontend/src/widgets/InstanceList.vue index 0d39d347..c7b62eb6 100644 --- a/frontend/src/widgets/InstanceList.vue +++ b/frontend/src/widgets/InstanceList.vue @@ -461,7 +461,7 @@ onMounted(async () => {
- {{ t("清空") }} + {{ t("TXT_CODE_7333c7f7") }} click: (event: MouseEvent) => { event.stopPropagation(); Modal.confirm({ - title: t("二次确认"), - content: t("确定向实例发出关闭指令吗?"), + title: t("TXT_CODE_893567ac"), + content: t("TXT_CODE_6da85509"), onOk: async () => { execInstanceAction(event, "stop"); } @@ -157,8 +157,8 @@ const instanceOperations = computed(() => click: async (event: MouseEvent) => { event.stopPropagation(); Modal.confirm({ - title: t("二次确认"), - content: t("确定重启实例吗?"), + title: t("TXT_CODE_893567ac"), + content: t("TXT_CODE_f6bd907d"), onOk: async () => { execInstanceAction(event, "restart"); } @@ -185,8 +185,8 @@ const instanceOperations = computed(() => click: async (event: MouseEvent) => { event.stopPropagation(); Modal.confirm({ - title: t("二次确认"), - content: t("确认强制终止运行实例吗?这可能会造成实例数据损坏。"), + title: t("TXT_CODE_893567ac"), + content: t("TXT_CODE_ec08484"), onOk: async () => { execInstanceAction(event, "kill"); } @@ -200,7 +200,7 @@ const instanceOperations = computed(() => area: true }, { - title: t("标签分组"), + title: t("TXT_CODE_78e88c3f"), icon: TagsOutlined, click: async (event: MouseEvent) => { event.stopPropagation(); diff --git a/languages/en_US.json b/languages/en_US.json index 2f04fcb5..cb0d5ed8 100644 --- a/languages/en_US.json +++ b/languages/en_US.json @@ -1928,5 +1928,20 @@ "TXT_CODE_b52cb76c": "Please select network mode", "TXT_CODE_2ab036a4": "Please enter the game server port", "TXT_CODE_c5b38d90": "The instance specifications for renewal do not match, and the renewal operation cannot be completed!", - "TXT_CODE_13411df7": "SSO login failed, please return to the original page and try to log in again!" + "TXT_CODE_13411df7": "SSO login failed, please return to the original page and try to log in again!", + "TXT_CODE_a2544278": "Instance tag", + "TXT_CODE_f84ae54f": "After an instance has a tag, MCSManager will automatically classify the instance by tag name for users to filter when displaying these instances. Tag names support any language.", + "TXT_CODE_2c1337d": "Tag list of this instance", + "TXT_CODE_e26d53d5": "Do not create too many new tags, which may cause confusion of elements on the interface and degrade panel performance.", + "TXT_CODE_3dd66d98": "New tag", + "TXT_CODE_67d1ea21": "Some optional tags", + "TXT_CODE_3ecee271": "These selectable tags are calculated from the instance list of the current page and do not include all existing tags. A maximum of 30 are displayed here", + "TXT_CODE_893567ac": "Second confirmation", + "TXT_CODE_6da85509": "Are you sure you want to send a shutdown command to the instance?", + "TXT_CODE_f6bd907d": "Are you sure you want to restart the instance?", + "TXT_CODE_ec08484": "Are you sure you want to forcefully terminate the running instance? This may cause instance data corruption.", + "TXT_CODE_78e88c3f": "Tag grouping", + "TXT_CODE_7333c7f7": "Clear", + "TXT_CODE_6d8bc58d": "Failed to save. A single tag only supports up to 9 characters!", + "TXT_CODE_dc9fb6ce": "Failed to save. A single instance only supports up to 6 tags!" } diff --git a/languages/zh_CN.json b/languages/zh_CN.json index d3c34108..399b79e3 100644 --- a/languages/zh_CN.json +++ b/languages/zh_CN.json @@ -1928,5 +1928,20 @@ "TXT_CODE_b52cb76c": "请选择网络模式", "TXT_CODE_2ab036a4": "请输入游戏服务器端口", "TXT_CODE_c5b38d90": "续费的实例规格不匹配,无法完成续费操作!", - "TXT_CODE_13411df7": "SSO 登录失败,请重新回到原页面尝试重新跳转登录!" + "TXT_CODE_13411df7": "SSO 登录失败,请重新回到原页面尝试重新跳转登录!", + "TXT_CODE_a2544278": "实例标签", + "TXT_CODE_f84ae54f": "实例拥有标签之后,MCSManager 在显示这些实例时,将自动按照标签名字对实例进行分类供用户筛选,标签名字支持任何语言。", + "TXT_CODE_2c1337d": "此实例的标签列表", + "TXT_CODE_e26d53d5": "请勿创建过多新标签,这可能会导致界面上元素混乱和面板性能下降。", + "TXT_CODE_3dd66d98": "新标签", + "TXT_CODE_67d1ea21": "部分可选标签", + "TXT_CODE_3ecee271": "这些可选择的标签由当前页实例列表计算而来,并不包含所有已存在的标签,此处最多展示 30 个", + "TXT_CODE_893567ac": "二次确认", + "TXT_CODE_6da85509": "确定向实例发出关闭指令吗?", + "TXT_CODE_f6bd907d": "确定重启实例吗?", + "TXT_CODE_ec08484": "确认强制终止运行实例吗?这可能会造成实例数据损坏。", + "TXT_CODE_78e88c3f": "标签分组", + "TXT_CODE_7333c7f7": "清空", + "TXT_CODE_6d8bc58d": "保存失败,单个标签最多只支持9个字符!", + "TXT_CODE_dc9fb6ce": "保存失败,单个实例最多只支持6个标签!" } diff --git a/panel/src/app/routers/instance_operate_router.ts b/panel/src/app/routers/instance_operate_router.ts index 9630f9a2..fdc78de6 100755 --- a/panel/src/app/routers/instance_operate_router.ts +++ b/panel/src/app/routers/instance_operate_router.ts @@ -375,11 +375,11 @@ router.put( if (config.tag instanceof Array && isTopPermissionByUuid(getUserUuid(ctx))) { instanceTags = (config.tag as any[]).map((tag: any) => { const tmp = String(tag).trim(); - if (tmp.length > 9) throw new Error($t("保存失败,单个标签最多只支持9个字符!")); + if (tmp.length > 9) throw new Error($t("TXT_CODE_6d8bc58d")); return tmp; }); if (instanceTags.length > 6) { - throw new Error($t("保存失败,单个实例最多只支持6个标签!")); + throw new Error($t("TXT_CODE_dc9fb6ce")); } instanceTags = instanceTags!.sort((a, b) => (a > b ? 1 : -1)); }