From 374d13934f96a405e5ea7b68ae8022064681c313 Mon Sep 17 00:00:00 2001 From: jingyang <3161362058@qq.com> Date: Wed, 10 Jul 2024 15:42:12 +0800 Subject: [PATCH] refactor: enhance i18n type annotations for better developer experience --- .gitignore | 1 - frontend/.vscode/settings.json | 20 ++ frontend/desktop/.vscode/settings.json | 19 ++ frontend/desktop/package.json | 6 +- .../desktop/public/locales/en/common.json | 189 ++++------- .../{cloudProviders.json => providers.json} | 2 +- .../desktop/public/locales/zh/common.json | 176 ++++++----- .../{cloudProviders.json => providers.json} | 0 .../desktop/src/components/AppDock/index.tsx | 2 +- .../src/components/LangSelect/simple.tsx | 2 +- .../desktop/src/components/account/cost.tsx | 2 +- .../desktop/src/components/account/index.tsx | 2 +- .../src/components/app_window/index.tsx | 5 +- .../src/components/desktop_content/apps.tsx | 5 +- .../components/desktop_content/assistant.tsx | 2 +- .../src/components/desktop_content/index.tsx | 2 +- .../components/desktop_content/monitor.tsx | 2 +- .../components/desktop_content/searchBox.tsx | 5 +- .../src/components/desktop_content/time.tsx | 2 +- .../src/components/desktop_content/warn.tsx | 2 +- .../src/components/floating_button/index.tsx | 2 +- .../src/components/more_apps/index.tsx | 5 +- .../src/components/more_button/index.tsx | 2 +- .../src/components/notification/index.tsx | 2 +- .../src/components/region/RegionToggle.tsx | 15 +- .../src/components/rightContext/index.tsx | 5 +- .../components/signin/auth/useCustomError.tsx | 5 +- .../components/signin/auth/usePassword.tsx | 2 +- .../components/signin/auth/useProtocol.tsx | 2 +- .../src/components/signin/auth/useSms.tsx | 2 +- .../src/components/signin/auth/useWechat.tsx | 2 +- .../desktop/src/components/signin/index.tsx | 2 +- .../src/components/team/Abdication.tsx | 2 +- .../src/components/team/CreateTeam.tsx | 2 +- .../src/components/team/DissolveTeam.tsx | 2 +- .../src/components/team/InviteMember.tsx | 2 +- .../src/components/team/ModifyRole.tsx | 2 +- .../src/components/team/NsListItem.tsx | 2 +- .../src/components/team/ReciveMessage.tsx | 2 +- .../src/components/team/RemoveMember.tsx | 2 +- .../src/components/team/TeamCenter.tsx | 2 +- .../src/components/team/WorkspaceToggle.tsx | 2 +- .../desktop/src/components/team/userTable.tsx | 2 +- frontend/desktop/src/hooks/useDriver.tsx | 2 +- .../desktop/src/pages/WorkspaceInvite.tsx | 2 +- frontend/desktop/src/pages/_app.tsx | 2 +- frontend/desktop/src/pages/index.tsx | 1 + frontend/desktop/src/pages/signin.tsx | 2 +- frontend/desktop/src/types/i18next.d.ts | 19 ++ frontend/desktop/tsconfig.json | 3 +- frontend/package.json | 7 +- frontend/packages/client-sdk/package.json | 2 +- frontend/pnpm-lock.yaml | 298 ++++++++++-------- frontend/providers/adminer/package.json | 6 +- frontend/providers/applaunchpad/.gitignore | 1 - .../applaunchpad/.vscode/settings.json | 19 ++ .../applaunchpad/next-i18next.config.js | 5 +- frontend/providers/applaunchpad/package.json | 6 +- .../public/locales/en/common.json | 146 ++++----- .../public/locales/zh/common.json | 142 +++++---- .../src/components/AppStatusTag/index.tsx | 6 +- .../src/components/GPUItem/index.tsx | 2 +- .../src/components/LangSelect/index.tsx | 4 +- .../applaunchpad/src/constants/editApp.ts | 5 +- .../applaunchpad/src/hooks/useConfirm.tsx | 15 +- .../src/hooks/useDetailDriver.tsx | 2 +- .../applaunchpad/src/hooks/useDriver.tsx | 2 +- .../applaunchpad/src/hooks/useRequest.tsx | 7 +- .../providers/applaunchpad/src/pages/_app.tsx | 2 +- .../app/detail/components/AppBaseInfo.tsx | 12 +- .../app/detail/components/AppMainInfo.tsx | 2 +- .../pages/app/detail/components/DelModal.tsx | 2 +- .../pages/app/detail/components/Header.tsx | 2 +- .../pages/app/detail/components/LogsModal.tsx | 2 +- .../app/detail/components/MonitorModal.tsx | 2 +- .../app/detail/components/PodDetailModal.tsx | 2 +- .../app/detail/components/PodFileModal.tsx | 2 +- .../src/pages/app/detail/components/Pods.tsx | 9 +- .../app/edit/components/ConfigmapModal.tsx | 4 +- .../app/edit/components/CustomAccessModal.tsx | 4 +- .../pages/app/edit/components/EditEnvs.tsx | 2 +- .../src/pages/app/edit/components/Form.tsx | 4 +- .../src/pages/app/edit/components/Header.tsx | 6 +- .../pages/app/edit/components/PriceBox.tsx | 4 +- .../pages/app/edit/components/QuotaBox.tsx | 3 +- .../pages/app/edit/components/StoreModal.tsx | 2 +- .../src/pages/app/edit/components/Yaml.tsx | 2 +- .../applaunchpad/src/pages/app/edit/index.tsx | 6 +- .../src/pages/apps/components/appList.tsx | 4 +- .../src/pages/apps/components/empty.tsx | 2 +- .../applaunchpad/src/pages/apps/index.tsx | 1 + .../applaunchpad/src/types/i18next.d.ts | 27 ++ .../providers/applaunchpad/src/utils/i18n.ts | 5 +- .../providers/applaunchpad/src/utils/tools.ts | 5 +- frontend/providers/cloudserver/.gitignore | 2 +- .../cloudserver/.vscode/settings.json | 7 + frontend/providers/cloudserver/package.json | 6 +- frontend/providers/costcenter/package.json | 6 +- frontend/providers/cronjob/package.json | 8 +- frontend/providers/dbprovider/package.json | 8 +- frontend/providers/invite/package.json | 6 +- frontend/providers/kubepanel/package.json | 3 + frontend/providers/license/package.json | 6 +- frontend/providers/objectstorage/package.json | 6 +- frontend/providers/template/package.json | 6 +- frontend/providers/terminal/package.json | 6 +- frontend/providers/workorder/package.json | 6 +- 107 files changed, 778 insertions(+), 636 deletions(-) create mode 100644 frontend/.vscode/settings.json create mode 100644 frontend/desktop/.vscode/settings.json rename frontend/desktop/public/locales/en/{cloudProviders.json => providers.json} (99%) rename frontend/desktop/public/locales/zh/{cloudProviders.json => providers.json} (100%) create mode 100644 frontend/desktop/src/types/i18next.d.ts create mode 100644 frontend/providers/applaunchpad/.vscode/settings.json create mode 100644 frontend/providers/applaunchpad/src/types/i18next.d.ts create mode 100644 frontend/providers/cloudserver/.vscode/settings.json diff --git a/.gitignore b/.gitignore index 4411fc345ffc..3e238537be2d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ tmp **/.DS_Store node_modules vendor -.vscode/ pkg/registry/save/testdata/registry .dummy.report.md deploy/cloud/tars diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json new file mode 100644 index 000000000000..cda4f7e86b9c --- /dev/null +++ b/frontend/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "i18n-ally.localesPaths": [ + "providers/**/public/locales", + "desktop/public/locales" + ], + "i18n-ally.enabledParsers": [ + "json", + "yaml", + "js", + "ts" + ], + "i18n-ally.keystyle": "nested", + "i18n-ally.sortKeys": true, + "i18n-ally.keepFulfilled": false, + "i18n-ally.sourceLanguage": "zh", + "i18n-ally.displayLanguage": "zh", + "i18n-ally.namespace": true, + "i18n-ally.pathMatcher": "{locale}/{namespaces}.json", + "i18n-ally.extract.targetPickingStrategy": "most-similar-by-key" +} \ No newline at end of file diff --git a/frontend/desktop/.vscode/settings.json b/frontend/desktop/.vscode/settings.json new file mode 100644 index 000000000000..488915e5da7d --- /dev/null +++ b/frontend/desktop/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "i18n-ally.localesPaths": [ + "public/locales" + ], + "i18n-ally.enabledParsers": [ + "json", + "yaml", + "js", + "ts" + ], + "i18n-ally.keystyle": "nested", + "i18n-ally.sortKeys": true, + "i18n-ally.keepFulfilled": false, + "i18n-ally.sourceLanguage": "zh", + "i18n-ally.displayLanguage": "zh", + "i18n-ally.namespace": true, + "i18n-ally.pathMatcher": "{locale}/{namespaces}.json", + "i18n-ally.extract.targetPickingStrategy": "most-similar-by-key" +} \ No newline at end of file diff --git a/frontend/desktop/package.json b/frontend/desktop/package.json index cf49f853ce6d..a3ecad8099c7 100644 --- a/frontend/desktop/package.json +++ b/frontend/desktop/package.json @@ -42,7 +42,7 @@ "eslint": "8.38.0", "eslint-config-next": "13.3.0", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^10.0.2", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -53,7 +53,7 @@ "mongodb": "^5.9.0", "nanoid": "^4.0.2", "next": "13.3.0", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "next-pwa": "^5.6.0", "nodemailer": "^6.9.13", "nprogress": "^0.2.0", @@ -65,7 +65,7 @@ "react-dom": "18.2.0", "react-draggable": "^4.4.6", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "sass": "^1.68.0", "sealos-desktop-sdk": "workspace:*", "sharp": "^0.32.6", diff --git a/frontend/desktop/public/locales/en/common.json b/frontend/desktop/public/locales/en/common.json index 5c133543c0dd..d8b8193615f0 100644 --- a/frontend/desktop/public/locales/en/common.json +++ b/frontend/desktop/public/locales/en/common.json @@ -1,22 +1,15 @@ { - "Cost Center": "Cost Center", - "Laf on Sealos": "Laf on Sealos", + "Abdication": "Abdication", + "Accept": "Accept", + "Accept Invitation": "Accept Invitation", + "Access": "Access", + "Account Settings": "Account Settings", + "Added": "Added", + "Alarm Pod": "Alarm Pod: {{count}}", + "Alerts": "Alerts", + "All Apps": "All Apps", + "App Info": "App Info", "App Launchpad": "App Launchpad", - "Database": "Database", - "Sealos Document": "Sealos Document", - "Terminal": "Terminal", - "More Apps": "More Apps", - "Message Center": "Message Center", - "Have Read": "Have read", - "Unread": "Unread", - "Read All": "Read All", - "Username": "Username", - "Log Out": "Log Out", - "Log In": "Log In", - "Password Login": "with Password", - "Verification Code Login": "with Phone", - "Loading": "Loading", - "From": "From", "Balance": "Balance", "password tips": "Password must be 8 characters or more", "username tips": "Username must be 3-16 characters, including letters, numbers", @@ -35,122 +28,68 @@ "Invalid phone number": "Invalid phone number", "Invalid username or password": "Invalid username or password", "Invalid verification code": "Invalid verification code", - "Get code failed": "Get code failed", - "Read and agree": "Please read and agree to the agreement below", - "agree policy": "I have read and agree to the", - "Service Agreement": "Service Agreement", - "and": "and", - "Privacy Policy": "Privacy Policy", - "Get Code": "verification", - "Total Amount": "Total Amount", - "Payment Result": "Payment Result", - "Payment Successful": "Payment Successful", - "In Payment": "In Payment ...", - "Bonus": "Bonus", - "Select Amount": "Select Amount", - "View Discount Rules": "View recharge discount rules.", - "Payment Status": "Payment Status", - "Scan with WeChat": "Scan with WeChat", - "Charge": "Charge", - "Order Number": "Order Number", - "Confirm": "Confirm", + "Invitation reminder": "Invitation reminder", + "Invite Member": "Invite Member", + "Invite members to workspace ": "Invite members to workspace {{workspace}}", + "Jump Over": "Jump Over", + "Laf on Sealos": "Laf on Sealos", + "Launch various third-party applications with one click": "Launch various third-party applications with one click", + "License Buy": "License Buy", + "Loading": "Loading", + "Log In": "Log In", + "Log Out": "Log Out", "Login to your account": "Login to your account", - "Abdication": "Abdication", - "Team": "Workspace", + "Manage Team": "Manage Workspace", "Member List": "Member List", - "Created Time": "Created Time", - "Create Team": "Create Workspace", - "noWorkspaceCreated": "You haven't created a workspace yet", + "Memory": "Memory", + "Message Center": "Message Center", + "Monitor": "Monitor", + "More Apps": "More Apps", "Name of Team": "Name of Workspace", - "Dissolve Team": "Delete Workspace", - "Invaild Name of Team": "Invaild Name of Workspace", - "Manage Team": "Manage Workspace", - "Default Team": "Personal Workspace", - "private team ID of user": "User's ID", - "Invite Member": "Invite Member", - "Handle": "Handle", - "Reject": "Reject", - "Accept": "Accept", - "Cancel": "Cancel", - "Quit": "Quit", - "Remove": "Remove", - "Warning": "Warning", - "User Name": "User Name", - "Access": "Access", - "In Time": "In Time", - "Status": "Status", + "Next time": "Next", + "No Apps Found": "No Apps Found", + "Official account login": "Official account login", "Operating": "Operating", - "Waiting": "Waiting", - "Added": "Added", - "Invaild Context": "You need switch to other workspace for handling", - "Remove Member Tips": "Determine that you want to remove the member?", - "Quit Workspace Tips": "Confirm leaving workspace?", - "Invalid User ID": "Invalid User ID", - "The invited user must be others": "The invited user must be others", - "Dissovle Tips": "Deleting the workspace will clear all resources. Are you sure you want to disband", - "Enter Confirm.": "Please enter {{value}} to confirm", - "Accept Invitation": "Accept Invitation", - "Receive Tips": "{{managerName}} invite you join in {{teamName}} as {{role}}", - "Invite members to workspace ": "Invite members to workspace {{workspace}}", - "Generate invitation link": "Generate invitation link", - "Failed to generate invitation link": "Failed to generate invitation link", - "Redirecting to homepage in 3 seconds": "Redirecting to homepage in 3 seconds", - "Invalid invitation link": "Invalid invitation link", - "Invitation reminder": "Invitation reminder", - "pay with stripe": "Pay With Stripe", - "pay with wechat": "Pay With Wechat", - "License Buy": "License Buy", + "Order Number": "Order Number", + "Password": "Password", + "Password Login": "with Password", + "Payment Result": "Payment Result", + "Payment Status": "Payment Status", + "Payment Successful": "Payment Successful", + "Please read and agree to the agreement": "Please read and agree to the agreement", + "Privacy Policy": "Privacy Policy", "Purchase History": "Purchase History", "Purchase License": "Purchase License", - "Remaining Time": "Remaining Time: ", - "Please read and agree to the agreement": "Please read and agree to the agreement", "Purchase Link Error": "Purchase Link Error", - "You have not purchased the License": "You have not purchased the License", - "App Info": "App Info", - "Click anywhere to continue": "Click on any blank space to continue", - "Jump Over": "Jump Over", - "Detail": "Detail", - "Hello, welcome": "Hello, welcome to", "Quick application switching floating ball": "Quick application switching floating ball", - "You can use the kubectl command directly from the terminal": "You can use the kubectl command directly from the terminal", - "Help you enable high availability database": "Help you enable high availability database", - "Launch various third-party applications with one click": "Launch various third-party applications with one click", - "You can view fees through the fee center": "You can view fees through the fee center", - "deploy an application": "Let’s deploy an application~", - "spend": "spend", - "Completed the deployment of an nginx for the first time": "Completed the deployment of an nginx for the first time", - "Next time": "Next", - "start immediately": "Start", - "Click on any shadow to skip": "Click on any shadow to skip", - "Start your Sealos journey": "Start your Sealos journey", - "gift amount": "Reward {{amount}} balance.", + "Quit": "Quit", + "Quit Workspace Tips": "Confirm leaving workspace?", + "Read All": "Read All", + "Read and agree": "Please read and agree to the agreement below", + "Receive Tips": "{{managerName}} invite you join in {{teamName}} as {{role}}", "Recharge Amount": "Recharge Amount", - "Doc": "Doc", - "Official account login": "Official account login", + "Redirecting to homepage in 3 seconds": "Redirecting to homepage in 3 seconds", "Region": "Region", - "Year": "Year", - "Core": "Core", - "Yuan": "Yuan", - "Description": "Description", - "All Apps": "All Apps", - "Account Settings": "Account Settings", - "Alerts": "Alerts", - "Monitor": "Monitor", - "Used Resources": "Used Resources", - "Memory": "Memory", - "Storage": "Storage", - "Flow": "Flow", - "Healthy Pod": "Healthy Pod: {{count}}", - "Alarm Pod": "Alarm Pod: {{count}}", - "Expected used": "Expected used", - "Used last month": "Used last month", - "Expected to use next month": "Expected to use next month", - "Day": "Day", + "Reject": "Reject", + "Remaining Time": "Remaining Time: ", + "Remove": "Remove", + "Remove Member Tips": "Determine that you want to remove the member?", + "Scan with WeChat": "Scan with WeChat", + "Sealos Copilot": "Sealos Copilot", + "Sealos Document": "Sealos Document", "Search Apps": "Search Apps", - "No Apps Found": "No Apps Found", + "Select Amount": "Select Amount", + "Service Agreement": "Service Agreement", + "Start your Sealos journey": "Start your Sealos journey", + "Status": "Status", + "Storage": "Storage", + "Submit Error": "Submit Error", "Switching Disc": "Switching Disc", + "Team": "Workspace", + "Terminal": "Terminal", + "The invited user must be others": "The invited user must be others", "Toggle App Bar": "Toggle App Bar", - "Work Order": "Work Order", + "Total Amount": "Total Amount", "Under active development": "Under active development 🚧", "Sealos Copilot": "Sealos Copilot", "Avatar": "Avatar", @@ -174,10 +113,10 @@ "deleteMyAccount": "DeleteMyAccount", "INSUFFICIENT_BALANCE_tips": "There is currently an outstanding balance in your account. In order to successfully complete the account cancellation process, please settle the outstanding balance first.", "Remain App Tips": "There are still undeleted application resources in your account. To help you smoothly complete the account cancellation process, please manually delete all application resources to avoid data loss", - "Remain Template Tips": "There are still undeleted template resources in your account. To help you smoothly complete the account cancellation process, please manually delete all template resources to avoid data loss", - "Remain ObjectStorage Tips": "There are still undeleted object storage resources in your account. To help you smoothly complete the account cancellation process, please manually delete all object storage resources to avoid data loss", - "Remain Database Tips": "There are still undeleted database resources in your account. To help you smoothly complete the account cancellation process, please manually delete all database resources to avoid data loss", - "Remain Workspace Tips": "There are still undeleted associated resources in your account. To help you successfully complete the account cancellation process, please clean up or transfer your workspace to avoid data loss.", + "Remain Template Tips": "There are still undeleted template resources in your account. To help you smoothly complete the account cancellation process, please manually delete all template resources to avoid data loss", + "Remain ObjectStorage Tips": "There are still undeleted object storage resources in your account. To help you smoothly complete the account cancellation process, please manually delete all object storage resources to avoid data loss", + "Remain Database Tips": "There are still undeleted database resources in your account. To help you smoothly complete the account cancellation process, please manually delete all database resources to avoid data loss", + "Remain Workspace Tips": "There are still undeleted associated resources in your account. To help you successfully complete the account cancellation process, please clean up or transfer your workspace to avoid data loss.", "Remain Other Region Resource Tips": "There are still associated resources that have not been deleted in your account. To help you successfully complete the account cancellation process, please clean up all region resources to ensure that nothing is missing.", "Delete Account Caution": "Once a resource is deleted, it cannot be recovered. \nTherefore, before performing the above operations, please be sure to back up your data.", "Enter": "Enter", @@ -200,4 +139,4 @@ "DeleteAccountTitle": "Sealos will permanently delete this account.", "MergeAccountTips1": "The account you are trying to bind has been used by another user. Due to conflicting binding methods, the accounts cannot be merged.", "DeleteAccountTips2": "The account you are trying to bind has been used by another user. You can choose to merge the accounts to unify the management of your information and settings. Would you like to merge the accounts now?" -} +} \ No newline at end of file diff --git a/frontend/desktop/public/locales/en/cloudProviders.json b/frontend/desktop/public/locales/en/providers.json similarity index 99% rename from frontend/desktop/public/locales/en/cloudProviders.json rename to frontend/desktop/public/locales/en/providers.json index 853501e3b41d..af71e006cfa8 100644 --- a/frontend/desktop/public/locales/en/cloudProviders.json +++ b/frontend/desktop/public/locales/en/providers.json @@ -8,4 +8,4 @@ "Singapore": "Singapore", "Guangzhou": "Guangzhou", "Hangzhou": "Hangzhou" -} +} \ No newline at end of file diff --git a/frontend/desktop/public/locales/zh/common.json b/frontend/desktop/public/locales/zh/common.json index 167eef87c261..ec9395bf5b09 100644 --- a/frontend/desktop/public/locales/zh/common.json +++ b/frontend/desktop/public/locales/zh/common.json @@ -50,100 +50,114 @@ "Confirm": "确认", "Login to your account": "登录您的帐户", "Abdication": "移交", - "Team": "工作空间", - "Member List": "成员列表", - "Created Time": "创建时间", - "Create Team": "创建工作空间", - "noWorkspaceCreated": "您还没有创建工作空间", - "Name of Team": "工作空间名称", - "Dissolve Team": "删除", - "Invaild Name of Team": "不合法的工作空间名称", - "Manage Team": "管理工作空间", - "Default Team": "个人空间", - "private team ID of user": "用户ID", - "Invite Member": "邀请成员", - "Handle": "操作", - "Reject": "拒绝", "Accept": "接受", - "Cancel": "取消", - "Quit": "退出", - "Remove": "移除", - "Warning": "警告", - "User Name": "用户名", + "Accept Invitation": "接受邀请", "Access": "权限", - "In Time": "加入时间", - "Status": "状态", - "Operating": "操作", - "Waiting": "等待中", + "Account Settings": "账户设置", "Added": "已加入", - "Invaild Context": "你需要切换到其他工作空间操作", - "Remove Member Tips": "确认要移除该成员?", - "Quit Workspace Tips": "确认要退出工作空间吗?", - "Invalid User ID": "用户的 ID 不合法", - "The invited user must be others": "只能邀请其他人", + "Alarm Pod": "告警 Pod: {{count}}", + "Alerts": "告警", + "All Apps": "所有应用", + "App Info": "应用信息", + "Balance": "余额", + "Bonus": "赠", + "Cancel": "取消", + "Charge": "充值", + "Click anywhere to continue": "点击任意空白继续", + "Click on any shadow to skip": "点击任意阴影跳过", + "Completed the deployment of an nginx for the first time": "部署一个 nginx ,首次完成 将", + "Confirm": "确认", + "Core": "核", + "Create Team": "创建工作空间", + "Created Time": "创建时间", + "Day": "天", + "Default Team": "个人空间", + "Description": "描述", + "Detail": "详情", + "Dissolve Team": "删除", "Dissovle Tips": "删除工作空间会清空所有资源,确定要删除吗?", + "Doc": "文档", "Enter Confirm.": "请输入 {{value}} 确认", - "Accept Invitation": "接受邀请", - "Receive Tips": "{{managerName}} 邀请你到 {{teamName}} 成为 {{role}}", - "Invite members to workspace": "邀请成员至工作空间 {{workspace}}", - "Generate invitation link": "生成邀请链接", + "Expected to use next month": "下月预计使用", + "Expected used": "预计还能使用", "Failed to generate invitation link": "生成邀请链接失败", - "Redirecting to homepage in 3 seconds": "3秒后跳回主页", + "Flow": "流量", + "From": "来自", + "Generate invitation link": "生成邀请链接", + "Get Code": "获取验证码", + "Get code failed": "获取验证码失败", + "Handle": "操作", + "Have Read": "已读", + "Healthy Pod": "健康 Pod: {{count}}", + "Hello, welcome": "您好, 欢迎来到", + "Help you enable high availability database": "帮您启用高可用数据库", + "In Payment": "支付中 ...", + "In Time": "加入时间", + "Invaild Context": "你需要切换到其他工作空间操作", + "Invaild Name of Team": "不合法的工作空间名称", + "Invalid User ID": "用户的 ID 不合法", "Invalid invitation link": "邀请链接非法", + "Invalid phone number": "无效的手机号码", + "Invalid username or password": "用户名或密码错误", + "Invalid verification code": "无效的验证码", "Invitation reminder": "受邀提醒", - "pay with wechat": "微信支付", - "pay with stripe": "Stripe 支付", + "Invite Member": "邀请成员", + "Invite members to workspace": "邀请成员至工作空间 {{workspace}}", + "Jump Over": "跳过", + "Launch various third-party applications with one click": "一键启动各种第三方应用", "License Buy": "License 购买", + "Loading": "加载中", + "Log In": "登录", + "Log Out": "登出", + "Login to your account": "登录您的帐户", + "Manage Team": "管理工作空间", + "Member List": "成员列表", + "Memory": "内存", + "Message Center": "消息中心", + "Monitor": "监控", + "More Apps": "更多应用", + "Name of Team": "工作空间名称", + "Next time": "下次吧", + "No Apps Found": "未找到任何应​​用", + "Official account login": "公众号登录", + "Operating": "操作", + "Order Number": "订单号", + "Password": "密码", + "Password Login": "密码登录", + "Payment Result": "支付结果", + "Payment Status": "支付状态", + "Payment Successful": "支付成功", + "Please read and agree to the agreement": "请阅读并同意协议", + "Privacy Policy": "隐私政策", "Purchase History": "购买记录", "Purchase License": "购买 License", - "Remaining Time": "剩余激活时间: ", - "Please read and agree to the agreement": "请阅读并同意协议", "Purchase Link Error": "购买链接错误", - "You have not purchased the License": "您还没有购买 License", - "App Info": "应用信息", - "Click anywhere to continue": "点击任意空白继续", - "Jump Over": "跳过", - "Detail": "详情", - "Hello, welcome": "您好, 欢迎来到", "Quick application switching floating ball": "快捷应用切换悬浮球", - "You can use the kubectl command directly from the terminal": "您可通过终端直接使用 kubectl 命令", - "Help you enable high availability database": "帮您启用高可用数据库", - "Launch various third-party applications with one click": "一键启动各种第三方应用", - "You can view fees through the fee center": "您可通过费用中心查看费用", - "deploy an application": "来部署一个应用吧~", - "spend": "花", - "Completed the deployment of an nginx for the first time": "部署一个 nginx ,首次完成 将", - "Next time": "下次吧", - "start immediately": "立即开始", - "Click on any shadow to skip": "点击任意阴影跳过", - "Start your Sealos journey": "开始您的 Sealos 之旅", - "gift amount": "赠送 {{amount}} 余额.", - "Doc": "文档", - "Official account login": "公众号登录", + "Quit": "退出", + "Quit Workspace Tips": "确认要退出工作空间吗?", + "Read All": "全部已读", + "Read and agree": "请阅读并同意下方协议", + "Receive Tips": "{{managerName}} 邀请你到 {{teamName}} 成为 {{role}}", + "Recharge Amount": "充值金额", + "Redirecting to homepage in 3 seconds": "3秒后跳回主页", "Region": "可用区", - "Year": "年", - "Core": "核", - "Yuan": "元", - "Description": "描述", - "All Apps": "所有应用", - "Account Settings": "账户设置", - "Alerts": "告警", - "Monitor": "监控", - "Used Resources": "已用资源", - "Memory": "内存", - "Storage": "存储", - "Flow": "流量", - "Healthy Pod": "健康 Pod: {{count}}", - "Alarm Pod": "告警 Pod: {{count}}", - "Expected used": "预计还能使用", - "Used last month": "上月已使用", - "Expected to use next month": "下月预计使用", - "Day": "天", + "Reject": "拒绝", + "Remaining Time": "剩余激活时间: ", + "Remove": "移除", + "Remove Member Tips": "确认要移除该成员?", + "Scan with WeChat": "微信扫码支付", + "Sealos Copilot": "Sealos 小助理", "Search Apps": "搜索应用", - "No Apps Found": "未找到任何应​​用", + "Select Amount": "选择金额", + "Service Agreement": "服务协议", + "Start your Sealos journey": "开始您的 Sealos 之旅", + "Status": "状态", + "Storage": "存储", + "Submit Error": "提交错误", "Switching Disc": "切换圆盘", + "Team": "工作空间", + "The invited user must be others": "只能邀请其他人", "Toggle App Bar": "切换应用栏", - "Work Order": "工单", "Under active development": "正在积极开发中 🚧", "Sealos Copilot": "Sealos 小助理", "Avatar": "头像", @@ -167,9 +181,9 @@ "deleteMyAccount": "删除我的账号", "INSUFFICIENT_BALANCE_tips": "您的账户目前存在未结清的款项,为了顺利完成账户注销流程,请先结清欠款。", "Remain App Tips": "您的账户中仍有未删除的应用资源,为了帮助您顺利完成账户注销流程,请您手动删除所有应用资源,以避免数据丢失", - "Remain Template Tips": "您的账户中仍有未删除的模板资源,为了帮助您顺利完成账户注销流程,请您手动删除所有模板资源,以避免数据丢失", - "Remain ObjectStorage Tips": "您的账户中仍有未删除的对象存储资源,为了帮助您顺利完成账户注销流程,请您手动删除所有对象存储资源,以避免数据丢失", - "Remain Database Tips": "您的账户中仍有未删除的数据库资源,为了帮助您顺利完成账户注销流程,请您手动删除所有数据库资源,以避免数据丢失", + "Remain Template Tips": "您的账户中仍有未删除的模板资源,为了帮助您顺利完成账户注销流程,请您手动删除所有模板资源,以避免数据丢失", + "Remain ObjectStorage Tips": "您的账户中仍有未删除的对象存储资源,为了帮助您顺利完成账户注销流程,请您手动删除所有对象存储资源,以避免数据丢失", + "Remain Database Tips": "您的账户中仍有未删除的数据库资源,为了帮助您顺利完成账户注销流程,请您手动删除所有数据库资源,以避免数据丢失", "Remain Workspace Tips": "您的账户中仍有未删除的关联资源,为了帮助您顺利完成账户注销流程,请您清理或转移您的工作空间,以避免数据丢失", "Remain Other Region Resource Tips": "您好,您的账户中仍有未删除的关联资源,为了帮助您顺利完成账户注销流程,请您清理所有可用区资源,确保无遗漏。", "Delete Account Caution": "资源一旦删除,将不可恢复。因此,在执行以上操作前,请务必做好数据备份工作", @@ -193,4 +207,4 @@ "DeleteAccountTitle": "Sealos 将永久删除此账户。", "MergeAccountTips1": "您尝试绑定的账号已被其他用户使用。由于存在冲突的其他绑定方式,无法合并账户。", "DeleteAccountTips2": "您尝试绑定的账号已被其他用户使用。您可以选择合并账户,以统一管理您的信息和设置。是否现在合并账户?" -} +} \ No newline at end of file diff --git a/frontend/desktop/public/locales/zh/cloudProviders.json b/frontend/desktop/public/locales/zh/providers.json similarity index 100% rename from frontend/desktop/public/locales/zh/cloudProviders.json rename to frontend/desktop/public/locales/zh/providers.json diff --git a/frontend/desktop/src/components/AppDock/index.tsx b/frontend/desktop/src/components/AppDock/index.tsx index b8098855a9e7..53fb9cd415b4 100644 --- a/frontend/desktop/src/components/AppDock/index.tsx +++ b/frontend/desktop/src/components/AppDock/index.tsx @@ -13,7 +13,7 @@ import { useTranslation } from 'next-i18next'; const APP_DOCK_MENU_ID = 'APP_DOCK_MENU_ID'; export default function AppDock() { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { installedApps: apps, runningInfo, diff --git a/frontend/desktop/src/components/LangSelect/simple.tsx b/frontend/desktop/src/components/LangSelect/simple.tsx index 2ff8f543f418..8fee0371fba5 100644 --- a/frontend/desktop/src/components/LangSelect/simple.tsx +++ b/frontend/desktop/src/components/LangSelect/simple.tsx @@ -5,7 +5,7 @@ import { EVENT_NAME } from 'sealos-desktop-sdk'; import { masterApp } from 'sealos-desktop-sdk/master'; export default function LangSelectSimple(props: FlexProps) { - const { t, i18n } = useTranslation(); + const { t, i18n } = useTranslation('common'); return ( s.openApp); const installApp = useAppStore((s) => s.installedApps); diff --git a/frontend/desktop/src/components/account/index.tsx b/frontend/desktop/src/components/account/index.tsx index b3381c4ea2bb..9b251eba9412 100644 --- a/frontend/desktop/src/components/account/index.tsx +++ b/frontend/desktop/src/components/account/index.tsx @@ -34,7 +34,7 @@ export default function Account() { const [showId, setShowId] = useState(true); const router = useRouter(); const { copyData } = useCopyData(); - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { delSession, session, setToken } = useSessionStore(); const user = session?.user; const queryclient = useQueryClient(); diff --git a/frontend/desktop/src/components/app_window/index.tsx b/frontend/desktop/src/components/app_window/index.tsx index c209c96ab131..7d5f4c83fa0b 100644 --- a/frontend/desktop/src/components/app_window/index.tsx +++ b/frontend/desktop/src/components/app_window/index.tsx @@ -7,6 +7,7 @@ import Draggable, { DraggableEventHandler } from 'react-draggable'; import styles from './index.module.scss'; import { useTranslation } from 'next-i18next'; import { useConfigStore } from '@/stores/config'; +import { I18nNamespaces } from '@/types/i18next'; export default function AppWindow(props: { style?: React.CSSProperties; @@ -24,7 +25,7 @@ export default function AppWindow(props: { maxZIndex } = useAppStore(); const logo = useConfigStore().layoutConfig?.logo; - const { t, i18n } = useTranslation(); + const { t, i18n } = useTranslation('common'); const wnapp = findAppInfoById(pid); const [position, setPosition] = useState({ x: 0, y: 0 }); const dragDom = useRef(null); @@ -120,7 +121,7 @@ export default function AppWindow(props: { {wnapp?.i18n?.[i18n?.language]?.name ? wnapp.i18n?.[i18n?.language]?.name - : t(wnapp?.name)} + : t(wnapp?.name as keyof I18nNamespaces['common'])} {wnapp.menuData?.helpDocs && ( {item?.i18n?.[i18n?.language]?.name ? item?.i18n?.[i18n?.language]?.name - : t(item?.name)} + : t(item?.name as keyof I18nNamespaces['common'])} ))} diff --git a/frontend/desktop/src/components/desktop_content/assistant.tsx b/frontend/desktop/src/components/desktop_content/assistant.tsx index f3e2798664a1..6929786eb51d 100644 --- a/frontend/desktop/src/components/desktop_content/assistant.tsx +++ b/frontend/desktop/src/components/desktop_content/assistant.tsx @@ -3,7 +3,7 @@ import { useMessage } from '@sealos/ui'; import { useTranslation } from 'next-i18next'; export default function Assistant() { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { message } = useMessage(); return ( diff --git a/frontend/desktop/src/components/desktop_content/index.tsx b/frontend/desktop/src/components/desktop_content/index.tsx index 167a92f3bc04..fbe6429deee8 100644 --- a/frontend/desktop/src/components/desktop_content/index.tsx +++ b/frontend/desktop/src/components/desktop_content/index.tsx @@ -36,7 +36,7 @@ export const blurBackgroundStyles = { }; export default function Desktop(props: any) { - const { t, i18n } = useTranslation(); + const { t, i18n } = useTranslation('common'); const { isAppBar, toggleShape } = useDesktopConfigStore(); const { installedApps: apps, runningInfo, openApp, setToHighestLayerById } = useAppStore(); const backgroundImage = useConfigStore().layoutConfig?.backgroundImage; diff --git a/frontend/desktop/src/components/desktop_content/monitor.tsx b/frontend/desktop/src/components/desktop_content/monitor.tsx index 4876320f17db..8284f0dab605 100644 --- a/frontend/desktop/src/components/desktop_content/monitor.tsx +++ b/frontend/desktop/src/components/desktop_content/monitor.tsx @@ -7,7 +7,7 @@ import { CpuIcon, FlowIcon, MemoryIcon, StorageIcon } from '../icons'; import { blurBackgroundStyles } from './index'; export default function Monitor({ needStyles = true }: { needStyles?: boolean }) { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { data } = useQuery(['appListQuery'], getResource, { cacheTime: 5 * 60 * 1000 }); diff --git a/frontend/desktop/src/components/desktop_content/searchBox.tsx b/frontend/desktop/src/components/desktop_content/searchBox.tsx index caba7042e99b..5ea1b80d31df 100644 --- a/frontend/desktop/src/components/desktop_content/searchBox.tsx +++ b/frontend/desktop/src/components/desktop_content/searchBox.tsx @@ -6,9 +6,10 @@ import { SearchIcon } from '@sealos/ui'; import { useTranslation } from 'next-i18next'; import { useRef, useState } from 'react'; import { blurBackgroundStyles } from './index'; +import { I18nNamespaces } from '@/types/i18next'; export default function SearchBox() { - const { t, i18n } = useTranslation(); + const { t, i18n } = useTranslation('common'); const logo = useConfigStore().layoutConfig?.logo; const { installedApps: apps, runningInfo, openApp, setToHighestLayerById } = useAppStore(); const inputRef = useRef(null); @@ -127,7 +128,7 @@ export default function SearchBox() { {app?.i18n?.[i18n?.language]?.name ? app?.i18n?.[i18n?.language]?.name - : t(app?.name)} + : t(app?.name as keyof I18nNamespaces['common'])} )) ) : ( diff --git a/frontend/desktop/src/components/desktop_content/time.tsx b/frontend/desktop/src/components/desktop_content/time.tsx index 35b75c01ad9c..a4d8558a5b40 100644 --- a/frontend/desktop/src/components/desktop_content/time.tsx +++ b/frontend/desktop/src/components/desktop_content/time.tsx @@ -15,7 +15,7 @@ const WeekDay = { export default function TimeComponent(props: any) { const [time, setTime] = useState(new Date().toString()); - const { i18n } = useTranslation(); + const { i18n } = useTranslation('common'); useEffect(() => { const timer = setInterval(() => { diff --git a/frontend/desktop/src/components/desktop_content/warn.tsx b/frontend/desktop/src/components/desktop_content/warn.tsx index 722b27a01545..798d51095968 100644 --- a/frontend/desktop/src/components/desktop_content/warn.tsx +++ b/frontend/desktop/src/components/desktop_content/warn.tsx @@ -5,7 +5,7 @@ import { blurBackgroundStyles } from './index'; import { useTranslation } from 'next-i18next'; export default function Warn() { - const { t } = useTranslation(); + const { t } = useTranslation('common'); return ( {item?.i18n?.[i18n?.language]?.name ? item?.i18n?.[i18n?.language]?.name - : t(item?.name)} + : t(item?.name as keyof I18nNamespaces['common'])} ))} diff --git a/frontend/desktop/src/components/more_button/index.tsx b/frontend/desktop/src/components/more_button/index.tsx index 036da34cb831..471b7f43c946 100644 --- a/frontend/desktop/src/components/more_button/index.tsx +++ b/frontend/desktop/src/components/more_button/index.tsx @@ -5,7 +5,7 @@ import Iconfont from '../iconfont'; import { useTranslation } from 'next-i18next'; export default function MoreButton() { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const moreAppsContent = useContext(MoreAppsContext); return ( diff --git a/frontend/desktop/src/components/notification/index.tsx b/frontend/desktop/src/components/notification/index.tsx index 782936f16d8b..99200db5da8c 100644 --- a/frontend/desktop/src/components/notification/index.tsx +++ b/frontend/desktop/src/components/notification/index.tsx @@ -18,7 +18,7 @@ type TNotification = { }; export default function Notification(props: TNotification) { - const { t, i18n } = useTranslation(); + const { t, i18n } = useTranslation('common'); const { disclosure, onAmount } = props; const { installedApps, openApp } = useAppStore(); const [readNotes, setReadNotes] = useState([]); diff --git a/frontend/desktop/src/components/region/RegionToggle.tsx b/frontend/desktop/src/components/region/RegionToggle.tsx index cb3d4f62eb49..829db4e1e7a5 100644 --- a/frontend/desktop/src/components/region/RegionToggle.tsx +++ b/frontend/desktop/src/components/region/RegionToggle.tsx @@ -11,12 +11,13 @@ import { useTranslation } from 'next-i18next'; import { useRouter } from 'next/router'; import { useMemo } from 'react'; import { DesktopExchangeIcon, ZoneIcon } from '../icons'; +import { I18nNamespaces } from '@/types/i18next'; export default function RegionToggle() { const disclosure = useDisclosure(); const { setWorkSpaceId, session } = useSessionStore(); - const { t, i18n } = useTranslation(); - const { t: providerT } = useTranslation('cloudProviders'); + const { t, i18n } = useTranslation('common'); + const { t: providerT } = useTranslation('providers'); const router = useRouter(); const { data, isSuccess } = useQuery(['regionlist'], getRegionList); const regionList = useMemo(() => data?.data?.regionList || [], [data]); @@ -68,7 +69,8 @@ export default function RegionToggle() { > - {providerT(curRegion?.location || '')} {curRegion?.description?.serial} + {providerT(curRegion?.location as keyof I18nNamespaces['providers'])} + {curRegion?.description?.serial} @@ -129,7 +131,8 @@ export default function RegionToggle() { mb={'12px'} > - {providerT(region?.location)} {region?.description?.serial} + {providerT(region?.location as keyof I18nNamespaces['providers'])}{' '} + {region?.description?.serial} {cpuPrice && ( @@ -145,7 +148,9 @@ export default function RegionToggle() { {providerT('Provider')} - {providerT(region?.description?.provider)} + {providerT( + region?.description?.provider as keyof I18nNamespaces['providers'] + )} diff --git a/frontend/desktop/src/components/rightContext/index.tsx b/frontend/desktop/src/components/rightContext/index.tsx index 8d67283aa080..73094d4e20b3 100644 --- a/frontend/desktop/src/components/rightContext/index.tsx +++ b/frontend/desktop/src/components/rightContext/index.tsx @@ -1,3 +1,4 @@ +import { I18nNamespaces } from '@/types/i18next'; import { Box, Flex, Icon, Text } from '@chakra-ui/react'; import { useTranslation } from 'next-i18next'; import { MouseEvent, ReactElement, ReactNode, useState } from 'react'; @@ -12,7 +13,7 @@ export type SideBarMenu = { export default function RightContext({ children }: { children: ReactNode }) { const [contextOpen, setContextOpen] = useState(false); const [xYPosistion, setXyPosistion] = useState({ x: 0, y: 0 }); - const { t } = useTranslation(); + const { t } = useTranslation('common'); const showNav = (e: MouseEvent) => { e.preventDefault(); @@ -79,7 +80,7 @@ export default function RightContext({ children }: { children: ReactNode }) { {item.icon} - {t(item.value)} + {t(item.value as keyof I18nNamespaces['common'])} ); })} diff --git a/frontend/desktop/src/components/signin/auth/useCustomError.tsx b/frontend/desktop/src/components/signin/auth/useCustomError.tsx index 6dc5b7ad5789..ef3566b759fe 100644 --- a/frontend/desktop/src/components/signin/auth/useCustomError.tsx +++ b/frontend/desktop/src/components/signin/auth/useCustomError.tsx @@ -3,9 +3,10 @@ import React, { useState, useEffect } from 'react'; import warnIcon from 'public/icons/warning.svg'; import closeIcon from 'public/icons/close_white.svg'; import { useTranslation } from 'next-i18next'; +import { I18nNamespaces } from '@/types/i18next'; const useCustomError = () => { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const [error, setError] = useState(''); const showError = (errorMessage: string, duration = 5000) => { @@ -42,7 +43,7 @@ const useCustomError = () => { p="10px" > - {t(error)} + {t(error as keyof I18nNamespaces['common'])} ); diff --git a/frontend/providers/applaunchpad/src/pages/app/edit/components/PriceBox.tsx b/frontend/providers/applaunchpad/src/pages/app/edit/components/PriceBox.tsx index 30cd06452cb0..0ca892a78052 100644 --- a/frontend/providers/applaunchpad/src/pages/app/edit/components/PriceBox.tsx +++ b/frontend/providers/applaunchpad/src/pages/app/edit/components/PriceBox.tsx @@ -65,7 +65,7 @@ const PriceBox = ({ }; pods: [number, number]; }) => { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { userSourcePrice } = useUserStore(); const theme = useTheme(); @@ -134,7 +134,7 @@ const PriceBox = ({ borderRadius={'10px'} mr={2} > - {t(item.label)}: + {t(item.label as any)}: {item.value} ))} diff --git a/frontend/providers/applaunchpad/src/pages/app/edit/components/QuotaBox.tsx b/frontend/providers/applaunchpad/src/pages/app/edit/components/QuotaBox.tsx index 6703e86050e5..dfadf5cf4175 100644 --- a/frontend/providers/applaunchpad/src/pages/app/edit/components/QuotaBox.tsx +++ b/frontend/providers/applaunchpad/src/pages/app/edit/components/QuotaBox.tsx @@ -27,9 +27,10 @@ const sourceMap = { const QuotaBox = () => { const theme = useTheme(); - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { userQuota, loadUserQuota } = useUserStore(); useQuery(['getUserQuota'], loadUserQuota); + console.log(userQuota); const quotaList = useMemo(() => { if (!userQuota) return []; diff --git a/frontend/providers/applaunchpad/src/pages/app/edit/components/StoreModal.tsx b/frontend/providers/applaunchpad/src/pages/app/edit/components/StoreModal.tsx index 53a07a89706c..ca02f2d3e86f 100644 --- a/frontend/providers/applaunchpad/src/pages/app/edit/components/StoreModal.tsx +++ b/frontend/providers/applaunchpad/src/pages/app/edit/components/StoreModal.tsx @@ -47,7 +47,7 @@ const StoreModal = ({ successCb: (e: StoreType) => void; closeCb: () => void; }) => { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const type = useMemo(() => (!!defaultValue.id ? 'create' : 'edit'), [defaultValue]); const minVal = useMemo( () => (isEditStore ? defaultValue.value : 1), diff --git a/frontend/providers/applaunchpad/src/pages/app/edit/components/Yaml.tsx b/frontend/providers/applaunchpad/src/pages/app/edit/components/Yaml.tsx index 4c345902c702..412df3ff4cd4 100644 --- a/frontend/providers/applaunchpad/src/pages/app/edit/components/Yaml.tsx +++ b/frontend/providers/applaunchpad/src/pages/app/edit/components/Yaml.tsx @@ -16,7 +16,7 @@ const Yaml = ({ yamlList = [], pxVal }: { yamlList: YamlItemType[]; pxVal: numbe const { name } = router.query as QueryType; const { copyData } = useCopyData(); const [selectedIndex, setSelectedIndex] = useState(0); - const { t } = useTranslation(); + const { t } = useTranslation('common'); return ( { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const formOldYamls = useRef([]); const crOldYamls = useRef([]); const oldAppEditData = useRef(); @@ -182,7 +182,7 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) => }); } toast({ - title: t(applySuccess), + title: t(applySuccess as any), status: 'success' }); @@ -331,7 +331,7 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) => if (quoteCheckRes) { return toast({ status: 'warning', - title: t(quoteCheckRes), + title: t(quoteCheckRes as any), duration: 5000, isClosable: true }); diff --git a/frontend/providers/applaunchpad/src/pages/apps/components/appList.tsx b/frontend/providers/applaunchpad/src/pages/apps/components/appList.tsx index 339707e4722e..0dcacb78997e 100644 --- a/frontend/providers/applaunchpad/src/pages/apps/components/appList.tsx +++ b/frontend/providers/applaunchpad/src/pages/apps/components/appList.tsx @@ -27,7 +27,7 @@ const AppList = ({ apps: AppListItemType[]; refetchApps: () => void; }) => { - const { t } = useTranslation(); + const { t } = useTranslation('common'); const { setLoading } = useGlobalStore(); const { userSourcePrice } = useUserStore(); const { toast } = useToast(); @@ -185,7 +185,7 @@ const AppList = ({ ...(userSourcePrice?.gpu ? [ { - title: t('GPU'), + title: t('GPU' as any), key: 'gpu', render: (item: AppListItemType) => } diff --git a/frontend/providers/applaunchpad/src/pages/apps/components/empty.tsx b/frontend/providers/applaunchpad/src/pages/apps/components/empty.tsx index 548f7cac11a3..d737a28510fb 100644 --- a/frontend/providers/applaunchpad/src/pages/apps/components/empty.tsx +++ b/frontend/providers/applaunchpad/src/pages/apps/components/empty.tsx @@ -7,7 +7,7 @@ import { useTranslation } from 'next-i18next'; const Empty = () => { const router = useRouter(); - const { t } = useTranslation(); + const { t } = useTranslation('common'); return ( { const router = useRouter(); diff --git a/frontend/providers/applaunchpad/src/types/i18next.d.ts b/frontend/providers/applaunchpad/src/types/i18next.d.ts new file mode 100644 index 000000000000..3ae302928f7a --- /dev/null +++ b/frontend/providers/applaunchpad/src/types/i18next.d.ts @@ -0,0 +1,27 @@ +import 'i18next'; + +import common from '../../public/locales/zh/common.json'; + +export interface I18nNamespaces { + common: typeof common; +} + +export type NestedKeys = T extends object + ? { + [K in keyof T]-?: K extends string + ? T[K] extends object + ? `${K}` | `${K}.${NestedKeys}` + : `${K}` + : never; + }[keyof T] + : never; + +export type I18nNsType = (keyof I18nNamespaces)[]; + +declare module 'i18next' { + interface CustomTypeOptions { + returnNull: false; + defaultNS: 'common'; + resources: I18nNamespaces; + } +} diff --git a/frontend/providers/applaunchpad/src/utils/i18n.ts b/frontend/providers/applaunchpad/src/utils/i18n.ts index 703a65b0b0f3..f3672d84c350 100644 --- a/frontend/providers/applaunchpad/src/utils/i18n.ts +++ b/frontend/providers/applaunchpad/src/utils/i18n.ts @@ -1,10 +1,11 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { LANG_KEY } from './cookieUtils'; +import { I18nNsType } from '@/types/i18next'; -export const serviceSideProps = (content: any) => { +export const serviceSideProps = (content: any, ns: I18nNsType = []) => { return serverSideTranslations( content.req.cookies[LANG_KEY] || 'zh', - undefined, + ['common', ...ns], null, content.locales ); diff --git a/frontend/providers/applaunchpad/src/utils/tools.ts b/frontend/providers/applaunchpad/src/utils/tools.ts index 32f1d6979d22..ca7fb0562bb2 100644 --- a/frontend/providers/applaunchpad/src/utils/tools.ts +++ b/frontend/providers/applaunchpad/src/utils/tools.ts @@ -8,6 +8,7 @@ import type { AppPatchPropsType } from '@/types/app'; import { YamlKindEnum } from './adapt'; import { useTranslation } from 'next-i18next'; import * as jsonpatch from 'fast-json-patch'; +import { I18nNamespaces } from '@/types/i18next'; export function formatSize(size: number, fixedNumber = 2) { const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; @@ -28,7 +29,7 @@ export const formatTime = (time: string | number | Date, format = 'YYYY-MM-DD HH */ export const useCopyData = () => { const { toast } = useToast(); - const { t } = useTranslation(); + const { t } = useTranslation('common'); return { copyData: (data: string, title: string = 'Copy Success') => { try { @@ -39,7 +40,7 @@ export const useCopyData = () => { document.execCommand('copy'); document.body.removeChild(textarea); toast({ - title: t(title), + title: t(title as any), status: 'success', duration: 1000 }); diff --git a/frontend/providers/cloudserver/.gitignore b/frontend/providers/cloudserver/.gitignore index 52364be8ecb2..708ca04b9cd4 100644 --- a/frontend/providers/cloudserver/.gitignore +++ b/frontend/providers/cloudserver/.gitignore @@ -35,7 +35,7 @@ yarn-error.log* *.tsbuildinfo next-env.d.ts /public/trainData/ -/.vscode/ +/ / platform.json .yalc/ yalc.lock diff --git a/frontend/providers/cloudserver/.vscode/settings.json b/frontend/providers/cloudserver/.vscode/settings.json new file mode 100644 index 000000000000..54bea83b2f81 --- /dev/null +++ b/frontend/providers/cloudserver/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "i18n-ally.localesPaths": [ + "public/locales" + ], + "i18n-ally.keystyle": "nested", + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/frontend/providers/cloudserver/package.json b/frontend/providers/cloudserver/package.json index 7ccce1513b3f..05bc6c7d2c1c 100644 --- a/frontend/providers/cloudserver/package.json +++ b/frontend/providers/cloudserver/package.json @@ -27,7 +27,7 @@ "decimal.js": "^10.4.3", "echarts": "^5.4.3", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -39,14 +39,14 @@ "multer": "1.4.5-lts.1", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "prettier": "^2.8.8", "react": "18.2.0", "react-day-picker": "^8.8.2", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "sass": "^1.68.0", diff --git a/frontend/providers/costcenter/package.json b/frontend/providers/costcenter/package.json index 14596c915fbc..6271cd8281ec 100644 --- a/frontend/providers/costcenter/package.json +++ b/frontend/providers/costcenter/package.json @@ -32,21 +32,21 @@ "echarts-for-react": "^3.0.2", "formik": "^2.4.5", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "mongodb": "^5.9.0", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "qrcode.react": "^3.1.0", "react": "18.2.0", "react-activation": "^0.12.4", "react-day-picker": "^8.8.2", "react-dom": "18.2.0", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "sealos-desktop-sdk": "workspace:*", "typescript": "^5.2.2", "zustand": "^4.4.1" diff --git a/frontend/providers/cronjob/package.json b/frontend/providers/cronjob/package.json index fdb8dbc21410..ae7f050606f4 100644 --- a/frontend/providers/cronjob/package.json +++ b/frontend/providers/cronjob/package.json @@ -20,8 +20,8 @@ "@emotion/styled": "^11.11.0", "@kubernetes/client-node": "^0.18.1", "@next/font": "13.1.6", - "@tanstack/react-query": "^4.35.3", "@sealos/ui": "workspace:^", + "@tanstack/react-query": "^4.35.3", "ansi_up": "^5.2.1", "axios": "^1.5.1", "cron-parser": "^4.9.0", @@ -30,7 +30,7 @@ "dayjs": "^1.11.10", "echarts": "^5.4.3", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -38,14 +38,14 @@ "lodash": "^4.17.21", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "prettier": "^2.8.8", "react": "18.2.0", "react-day-picker": "^8.8.2", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "sass": "^1.68.0", diff --git a/frontend/providers/dbprovider/package.json b/frontend/providers/dbprovider/package.json index 17071f72e1ba..a9439b9873bc 100644 --- a/frontend/providers/dbprovider/package.json +++ b/frontend/providers/dbprovider/package.json @@ -20,6 +20,7 @@ "@emotion/styled": "^11.11.0", "@kubernetes/client-node": "^0.18.1", "@next/font": "13.1.6", + "@sealos/ui": "workspace:^", "@tanstack/react-query": "^4.35.3", "ansi_up": "^5.2.1", "axios": "^1.5.1", @@ -28,7 +29,7 @@ "echarts": "^5.4.3", "framer-motion": "^10.16.4", "github-markdown-css": "^5.2.0", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -38,19 +39,18 @@ "multer": "1.4.5-lts.1", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "prettier": "^2.8.8", "react": "18.2.0", "react-day-picker": "^8.8.2", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "sass": "^1.68.0", "sealos-desktop-sdk": "workspace:*", - "@sealos/ui": "workspace:^", "typescript": "^5.2.2", "zustand": "^4.4.1" }, diff --git a/frontend/providers/invite/package.json b/frontend/providers/invite/package.json index 3b05447ba513..973033da4a23 100644 --- a/frontend/providers/invite/package.json +++ b/frontend/providers/invite/package.json @@ -25,7 +25,7 @@ "dayjs": "^1.11.10", "echarts": "^5.4.3", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -34,14 +34,14 @@ "mongodb": "^5.9.0", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "prettier": "^2.8.8", "react": "18.2.0", "react-day-picker": "^8.8.2", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "sass": "^1.68.0", diff --git a/frontend/providers/kubepanel/package.json b/frontend/providers/kubepanel/package.json index ddd2c9261919..d60bdcf831d3 100644 --- a/frontend/providers/kubepanel/package.json +++ b/frontend/providers/kubepanel/package.json @@ -22,16 +22,19 @@ "byline": "^5.0.0", "eventsource": "^2.0.2", "framer-motion": "^10.16.4", + "i18next": "^23.11.5", "immer": "^10.0.3", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "moment": "^2.29.4", "moment-timezone": "^0.5.43", "next": "13.5.4", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "prettier": "^2.8.8", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-i18next": "^14.1.2", "react-icons": "^5.0.1", "rfc6902": "^5.0.1", "sealos-desktop-sdk": "workspace:*", diff --git a/frontend/providers/license/package.json b/frontend/providers/license/package.json index b29fe1a41937..aec775efd0e0 100644 --- a/frontend/providers/license/package.json +++ b/frontend/providers/license/package.json @@ -29,7 +29,7 @@ "decimal.js": "^10.4.3", "echarts": "^5.4.3", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -39,7 +39,7 @@ "mongodb": "^5.9.0", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "node-cron": "^3.0.3", "nprogress": "^0.2.0", "prettier": "^2.8.8", @@ -47,7 +47,7 @@ "react-day-picker": "^8.8.2", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "sass": "^1.68.0", diff --git a/frontend/providers/objectstorage/package.json b/frontend/providers/objectstorage/package.json index 93f81a2f6d7b..62d2423ce473 100644 --- a/frontend/providers/objectstorage/package.json +++ b/frontend/providers/objectstorage/package.json @@ -27,18 +27,18 @@ "echarts-for-react": "^3.0.2", "framer-motion": "^10.16.4", "fuse.js": "^7.0.0", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^10.0.3", "js-yaml": "^4.1.0", "jszip": "^3.10.1", "lodash": "^4.17.21", "next": "13.5.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "react": "^18", "react-dom": "^18", "react-dropzone": "^14.2.3", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "sealos-desktop-sdk": "workspace:^", "typescript": "^5.2.2", diff --git a/frontend/providers/template/package.json b/frontend/providers/template/package.json index 1d6318cae6ca..7c0f55ad8b31 100644 --- a/frontend/providers/template/package.json +++ b/frontend/providers/template/package.json @@ -34,7 +34,7 @@ "echarts": "^5.4.3", "fast-json-patch": "^3.1.1", "github-markdown-css": "^5.2.0", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -42,7 +42,7 @@ "lodash": "^4.17.21", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "node-cron": "^3.0.3", "nprogress": "^0.2.0", "octokit": "^3.1.1", @@ -50,7 +50,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "rehype-raw": "^6.1.1", diff --git a/frontend/providers/terminal/package.json b/frontend/providers/terminal/package.json index 0ca2f2b5c3ef..e39c37bab640 100644 --- a/frontend/providers/terminal/package.json +++ b/frontend/providers/terminal/package.json @@ -15,16 +15,16 @@ "clsx": "^1.2.1", "eslint": "8.36.0", "eslint-config-next": "13.2.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "nanoid": "^4.0.2", "next": "13.2.4", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "react": "18.2.0", "react-dom": "18.2.0", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "sealos-desktop-sdk": "workspace:*", "typescript": "^5.2.2", "zustand": "^4.4.1" diff --git a/frontend/providers/workorder/package.json b/frontend/providers/workorder/package.json index 03f83a955bea..334a7de1151e 100644 --- a/frontend/providers/workorder/package.json +++ b/frontend/providers/workorder/package.json @@ -28,7 +28,7 @@ "dayjs": "^1.11.10", "echarts": "^5.4.3", "framer-motion": "^10.16.4", - "i18next": "^22.5.1", + "i18next": "^23.11.5", "immer": "^9.0.21", "js-cookie": "^3.0.5", "js-yaml": "^4.1.0", @@ -40,14 +40,14 @@ "multer": "1.4.5-lts.1", "nanoid": "^4.0.2", "next": "13.1.6", - "next-i18next": "^13.3.0", + "next-i18next": "^15.3.0", "nprogress": "^0.2.0", "prettier": "^2.8.8", "react": "18.2.0", "react-day-picker": "^8.8.2", "react-dom": "18.2.0", "react-hook-form": "^7.46.2", - "react-i18next": "^12.3.1", + "react-i18next": "^14.1.2", "react-markdown": "^8.0.7", "react-syntax-highlighter": "^15.5.0", "remark-breaks": "^4.0.0",