扩充多语言范围,新增7种多语言

This commit is contained in:
xintaofei
2026-03-09 15:31:34 +08:00
parent 32fbafa1fe
commit 08b33b5755
18 changed files with 9457 additions and 75 deletions

View File

@@ -9,7 +9,18 @@ const withNextIntl = createNextIntlPlugin({
messages: {
path: "./src/i18n/messages",
format: "json",
locales: ["en", "zh-CN", "zh-TW"],
locales: [
"en",
"zh-CN",
"zh-TW",
"ja",
"ko",
"es",
"de",
"fr",
"pt",
"ar",
],
precompile: true,
},
},

View File

@@ -13,6 +13,13 @@ pub enum AppLocale {
En,
ZhCn,
ZhTw,
Ja,
Ko,
Es,
De,
Fr,
Pt,
Ar,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]

View File

@@ -239,6 +239,7 @@ export function AppI18nProvider({
useEffect(() => {
document.documentElement.lang = activeIntlLocale
document.documentElement.dir = activeIntlLocale === "ar" ? "rtl" : "ltr"
}, [activeIntlLocale])
const contextValue = useMemo<AppI18nContextValue>(

View File

@@ -36,9 +36,10 @@ import {
normalizeAppUpdateError,
relaunchApp,
} from "@/lib/updater"
import { APP_LOCALES } from "@/lib/i18n"
const PROXY_EXAMPLE = "http://127.0.0.1:7890"
const APP_LANGUAGE_VALUES = ["en", "zh_cn", "zh_tw"] as const
const APP_LANGUAGE_VALUES = APP_LOCALES
type LanguageSelectValue = "system" | AppLocale
@@ -83,6 +84,13 @@ export function SystemNetworkSettings() {
en: tLanguage("english"),
zh_cn: tLanguage("simplifiedChinese"),
zh_tw: tLanguage("traditionalChinese"),
ja: tLanguage("japanese"),
ko: tLanguage("korean"),
es: tLanguage("spanish"),
de: tLanguage("german"),
fr: tLanguage("french"),
pt: tLanguage("portuguese"),
ar: tLanguage("arabic"),
}),
[tLanguage]
)
@@ -362,6 +370,13 @@ export function SystemNetworkSettings() {
<SelectItem value="en">{languageLabels.en}</SelectItem>
<SelectItem value="zh_cn">{languageLabels.zh_cn}</SelectItem>
<SelectItem value="zh_tw">{languageLabels.zh_tw}</SelectItem>
<SelectItem value="ja">{languageLabels.ja}</SelectItem>
<SelectItem value="ko">{languageLabels.ko}</SelectItem>
<SelectItem value="es">{languageLabels.es}</SelectItem>
<SelectItem value="de">{languageLabels.de}</SelectItem>
<SelectItem value="fr">{languageLabels.fr}</SelectItem>
<SelectItem value="pt">{languageLabels.pt}</SelectItem>
<SelectItem value="ar">{languageLabels.ar}</SelectItem>
</SelectContent>
</Select>
</div>

12
src/i18n/global.d.ts vendored
View File

@@ -2,7 +2,17 @@ import type enMessages from "@/i18n/messages/en.json"
declare module "next-intl" {
interface AppConfig {
Locale: "en" | "zh-CN" | "zh-TW"
Locale:
| "en"
| "zh-CN"
| "zh-TW"
| "ja"
| "ko"
| "es"
| "de"
| "fr"
| "pt"
| "ar"
Messages: typeof enMessages
}
}

View File

@@ -12,6 +12,20 @@ async function loadMessages(locale: AppLocale): Promise<AbstractIntlMessages> {
return (await import("@/i18n/messages/zh-CN.json")).default
case "zh_tw":
return (await import("@/i18n/messages/zh-TW.json")).default
case "ja":
return (await import("@/i18n/messages/ja.json")).default
case "ko":
return (await import("@/i18n/messages/ko.json")).default
case "es":
return (await import("@/i18n/messages/es.json")).default
case "de":
return (await import("@/i18n/messages/de.json")).default
case "fr":
return (await import("@/i18n/messages/fr.json")).default
case "pt":
return (await import("@/i18n/messages/pt.json")).default
case "ar":
return (await import("@/i18n/messages/ar.json")).default
case "en":
default:
return enMessages

1320
src/i18n/messages/ar.json Normal file

File diff suppressed because it is too large Load Diff

1320
src/i18n/messages/de.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,14 @@
"followSystem": "Follow System",
"english": "English",
"simplifiedChinese": "Simplified Chinese",
"traditionalChinese": "Traditional Chinese"
"traditionalChinese": "Traditional Chinese",
"japanese": "Japanese",
"korean": "Korean",
"spanish": "Spanish",
"german": "German",
"french": "French",
"portuguese": "Portuguese",
"arabic": "Arabic"
},
"WelcomePage": {
"title": "Welcome to Codeg",

1320
src/i18n/messages/es.json Normal file

File diff suppressed because it is too large Load Diff

1320
src/i18n/messages/fr.json Normal file

File diff suppressed because it is too large Load Diff

1320
src/i18n/messages/ja.json Normal file

File diff suppressed because it is too large Load Diff

1320
src/i18n/messages/ko.json Normal file

File diff suppressed because it is too large Load Diff

1320
src/i18n/messages/pt.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,16 @@
{
"Language": {
"followSystem": "跟随系统",
"english": "English",
"english": "英语",
"simplifiedChinese": "简体中文",
"traditionalChinese": "繁體中文"
"traditionalChinese": "繁體中文",
"japanese": "日语",
"korean": "韩语",
"spanish": "西班牙语",
"german": "德语",
"french": "法语",
"portuguese": "葡萄牙语",
"arabic": "阿拉伯语"
},
"WelcomePage": {
"title": "欢迎使用Codeg",
@@ -74,7 +81,7 @@
"resolvedTheme": {
"light": "浅色",
"dark": "深色",
"unknown": "--"
"unknown": "未知"
}
},
"SystemSettings": {
@@ -193,7 +200,7 @@
"emptySkills": "暂无 Skill可点击“新建 Skill”。",
"newSkillTitle": "新建 Skill",
"skillInfo": "Skill 信息",
"skillIdPlaceholder": "skill-id (letters/numbers/-/_/.)",
"skillIdPlaceholder": "Skill ID例如my-skill",
"skillsDirectoryWithPath": "Skills目录{path}",
"skillsDirectoryNeedId": "Skills目录请输入 Skill ID 以生成完整路径",
"markdownContent": "Markdown 内容",
@@ -318,20 +325,20 @@
"empty": "暂无 MCP 结果。",
"loadingDetail": "加载市场详情...",
"detailLoadFailed": "加载详情失败:{message}",
"owner": "Owner: {owner}",
"namespace": "Namespace: {namespace}",
"owner": "所有者:{owner}",
"namespace": "命名空间:{namespace}",
"defaultInstallProtocol": "默认安装协议",
"currentOptionParameterCount": "当前选项参数数:{count}",
"installConfigDescription": "安装配置(JSON可修改后安装修改后将覆盖协议/参数表单)",
"selectLeftToView": "请选择左侧市场 MCP 查看详情。"
},
"badges": {
"verified": "Verified",
"remote": "Remote",
"hasHomepage": "Has Homepage",
"uses": "{count} uses",
"deployed": "Deployed",
"notDeployed": "Not Deployed"
"verified": "已验证",
"remote": "远程",
"hasHomepage": "有主页",
"uses": "{count} 次使用",
"deployed": "已部署",
"notDeployed": "未部署"
},
"selectLeftMcp": "请选择左侧 MCP。"
},
@@ -625,8 +632,8 @@
"prompting": "响应中...",
"error": "连接异常",
"disconnected": "未连接",
"tooltip": "{agent} - {status}",
"tooltipError": "{agent} - {error}"
"tooltip": "{agent}{status}",
"tooltipError": "{agent}{error}"
},
"tasks": {
"title": "任务"
@@ -653,10 +660,10 @@
},
"auxPanel": {
"tabs": {
"diff": "Diff",
"files": "Files",
"changes": "Changes",
"commits": "Commits"
"diff": "差异",
"files": "文件",
"changes": "变更",
"commits": "提交"
}
},
"windowControls": {
@@ -712,7 +719,7 @@
"fileCount": "{count} 个文件",
"openFileOrDiff": "从右侧面板打开文件或差异",
"disk": "磁盘",
"head": "HEAD",
"head": "HEAD(当前提交)",
"unsaved": "未保存",
"workingTree": "工作区",
"loading": "加载中...",
@@ -817,7 +824,7 @@
"addToVcs": "添加到 VCS"
},
"aria": {
"selectFile": "{action} {path}",
"selectFile": "{action}{path}",
"unselectAllFiles": "取消选择全部文件",
"selectAllFiles": "选择全部文件",
"unselectTracked": "取消选择已跟踪改动",
@@ -833,13 +840,13 @@
"commitMessage": "提交消息",
"commitMessagePlaceholder": "输入提交信息...",
"commitButton": "提交 ({count})",
"head": "HEAD",
"workingTree": "Working Tree",
"head": "HEAD(当前提交)",
"workingTree": "工作区",
"clickFileToDiff": "点击文件名查看差异",
"loadingDiff": "加载差异..."
},
"gitLogTab": {
"filesTitle": "Files",
"filesTitle": "文件",
"expandAllFiles": "展开全部文件",
"collapseAllFiles": "折叠全部文件",
"workspace": "工作区",
@@ -953,7 +960,7 @@
"addToVcs": "添加到 VCS"
},
"aria": {
"selectPath": "{action} {path}"
"selectPath": "{action}{path}"
},
"toasts": {
"openDirectoryFailed": "打开目录失败",
@@ -978,8 +985,8 @@
"renameDirectory": "重命名目录",
"renameFile": "重命名文件",
"description": "输入新的名称(仅名称,不含路径)。",
"placeholderDirectory": "new-folder-name",
"placeholderFile": "new-file-name.ext"
"placeholderDirectory": "新建文件夹名称",
"placeholderFile": "新建文件名称.ext"
},
"directoryDialog": {
"descriptionAdd": "选择目录 {path} 下要添加到 VCS 的文件。",
@@ -1059,13 +1066,13 @@
"noDiffOutput": "无差异输出。",
"diffTitleWorkspace": "Diff · 工作区",
"diffDescriptionWorkingTree": "工作区变更HEAD",
"diffTitleFile": "Diff · {name}",
"diffTitleFile": "差异 · {name}",
"compareTitleFile": "比较 · {name}",
"compareTitleBranch": "比较 · {branch}",
"compareDescriptionPath": "{path} · 与 {branch} 比较",
"compareDescriptionBranch": "与 {branch} 比较",
"diffTitleCommitFile": "Diff · {name} @ {hash}",
"diffTitleCommit": "Diff · {hash}",
"diffTitleCommitFile": "差异 · {name} @ {hash}",
"diffTitleCommit": "差异 · {hash}",
"diffDescriptionCommitPath": "{path} · 提交 {commit}",
"diffDescriptionCommit": "提交 {commit}",
"diffTitleConflictFile": "冲突 · {name}",
@@ -1078,7 +1085,7 @@
"retry": "重试"
},
"agentsSetupHint": "点击前往设置 > Agents 管理安装。",
"withSetupHint": "{message}\n{hint}",
"withSetupHint": "{message}\n提示:{hint}",
"blocked": {
"missingConfig": "无法读取当前 Agent 配置。",
"disabled": "{agent} 已在 Agents 管理中禁用,请先启用后再连接。",
@@ -1195,7 +1202,7 @@
"streaming": "生成中",
"elapsedMinutes": "{value} 分钟",
"elapsedSeconds": "{value} 秒",
"toolUseCount": "{count} 工具调用"
"toolUseCount": "{count} 工具 {count, plural, one {use} other {uses}}"
},
"tool": {
"parameters": "参数",
@@ -1243,14 +1250,14 @@
"nameLabel": "名称:",
"field": {
"file": "文件",
"notebook": "Notebook",
"notebook": "笔记本",
"command": "命令",
"old": "旧内容",
"new": "新内容",
"pattern": "模式",
"path": "路径",
"query": "查询",
"url": "URL",
"url": "URL地址",
"description": "描述",
"content": "内容",
"source": "源内容",

View File

@@ -1,9 +1,16 @@
{
"Language": {
"followSystem": "跟隨系統",
"english": "English",
"simplifiedChinese": "简体中文",
"traditionalChinese": "繁體中文"
"english": "英文",
"simplifiedChinese": "簡體中文",
"traditionalChinese": "繁體中文",
"japanese": "日語",
"korean": "韓語",
"spanish": "西班牙語",
"german": "德語",
"french": "法語",
"portuguese": "葡萄牙語",
"arabic": "阿拉伯語"
},
"WelcomePage": {
"title": "歡迎使用Codeg",
@@ -74,7 +81,7 @@
"resolvedTheme": {
"light": "淺色",
"dark": "深色",
"unknown": "--"
"unknown": "未知"
}
},
"SystemSettings": {
@@ -193,7 +200,7 @@
"emptySkills": "暫無 Skill可點擊「新增 Skill」。",
"newSkillTitle": "新增 Skill",
"skillInfo": "Skill 資訊",
"skillIdPlaceholder": "skill-id (letters/numbers/-/_/.)",
"skillIdPlaceholder": "Skill ID例如my-skill",
"skillsDirectoryWithPath": "Skills目錄{path}",
"skillsDirectoryNeedId": "Skills目錄請輸入 Skill ID 以產生完整路徑",
"markdownContent": "Markdown 內容",
@@ -318,20 +325,20 @@
"empty": "暫無 MCP 結果。",
"loadingDetail": "載入市場詳情...",
"detailLoadFailed": "載入詳情失敗:{message}",
"owner": "Owner: {owner}",
"namespace": "Namespace: {namespace}",
"owner": "擁有者:{owner}",
"namespace": "命名空間:{namespace}",
"defaultInstallProtocol": "預設安裝協議",
"currentOptionParameterCount": "目前選項參數數:{count}",
"installConfigDescription": "安裝配置(JSON可修改後安裝修改後將覆蓋協議/參數表單)",
"selectLeftToView": "請選擇左側市場 MCP 查看詳情。"
},
"badges": {
"verified": "Verified",
"remote": "Remote",
"hasHomepage": "Has Homepage",
"uses": "{count} uses",
"deployed": "Deployed",
"notDeployed": "Not Deployed"
"verified": "已驗證",
"remote": "遠端",
"hasHomepage": "有首頁",
"uses": "{count} 次使用",
"deployed": "已部署",
"notDeployed": "未部署"
},
"selectLeftMcp": "請選擇左側 MCP。"
},
@@ -625,8 +632,8 @@
"prompting": "回應中...",
"error": "連線異常",
"disconnected": "未連線",
"tooltip": "{agent} - {status}",
"tooltipError": "{agent} - {error}"
"tooltip": "{agent}{status}",
"tooltipError": "{agent}{error}"
},
"tasks": {
"title": "任務"
@@ -653,10 +660,10 @@
},
"auxPanel": {
"tabs": {
"diff": "Diff",
"files": "Files",
"changes": "Changes",
"commits": "Commits"
"diff": "差異",
"files": "檔案",
"changes": "變更",
"commits": "提交"
}
},
"windowControls": {
@@ -712,7 +719,7 @@
"fileCount": "{count} 個檔案",
"openFileOrDiff": "從右側面板打開檔案或差異",
"disk": "磁碟",
"head": "HEAD",
"head": "HEAD(目前提交)",
"unsaved": "未儲存",
"workingTree": "工作區",
"loading": "載入中...",
@@ -817,7 +824,7 @@
"addToVcs": "加入到 VCS"
},
"aria": {
"selectFile": "{action} {path}",
"selectFile": "{action}{path}",
"unselectAllFiles": "取消選擇全部檔案",
"selectAllFiles": "選擇全部檔案",
"unselectTracked": "取消選擇已追蹤變更",
@@ -833,13 +840,13 @@
"commitMessage": "提交訊息",
"commitMessagePlaceholder": "輸入提交訊息...",
"commitButton": "提交 ({count})",
"head": "HEAD",
"workingTree": "Working Tree",
"head": "HEAD(目前提交)",
"workingTree": "工作目錄",
"clickFileToDiff": "點擊檔案名稱查看差異",
"loadingDiff": "載入差異中..."
},
"gitLogTab": {
"filesTitle": "Files",
"filesTitle": "檔案",
"expandAllFiles": "展開全部檔案",
"collapseAllFiles": "折疊全部檔案",
"workspace": "工作區",
@@ -953,7 +960,7 @@
"addToVcs": "加入到 VCS"
},
"aria": {
"selectPath": "{action} {path}"
"selectPath": "{action}{path}"
},
"toasts": {
"openDirectoryFailed": "開啟目錄失敗",
@@ -978,8 +985,8 @@
"renameDirectory": "重新命名目錄",
"renameFile": "重新命名檔案",
"description": "輸入新的名稱(僅名稱,不含路徑)。",
"placeholderDirectory": "new-folder-name",
"placeholderFile": "new-file-name.ext"
"placeholderDirectory": "新資料夾名稱",
"placeholderFile": "新檔案名稱.ext"
},
"directoryDialog": {
"descriptionAdd": "選擇目錄 {path} 下要加入到 VCS 的檔案。",
@@ -1059,13 +1066,13 @@
"noDiffOutput": "無差異輸出。",
"diffTitleWorkspace": "Diff · 工作區",
"diffDescriptionWorkingTree": "工作區變更HEAD",
"diffTitleFile": "Diff · {name}",
"diffTitleFile": "差異 · {name}",
"compareTitleFile": "比較 · {name}",
"compareTitleBranch": "比較 · {branch}",
"compareDescriptionPath": "{path} · 與 {branch} 比較",
"compareDescriptionBranch": "與 {branch} 比較",
"diffTitleCommitFile": "Diff · {name} @ {hash}",
"diffTitleCommit": "Diff · {hash}",
"diffTitleCommitFile": "差異 · {name} @ {hash}",
"diffTitleCommit": "差異 · {hash}",
"diffDescriptionCommitPath": "{path} · 提交 {commit}",
"diffDescriptionCommit": "提交 {commit}",
"diffTitleConflictFile": "衝突 · {name}",
@@ -1078,7 +1085,7 @@
"retry": "重試"
},
"agentsSetupHint": "點擊前往設定 > Agents 管理安裝。",
"withSetupHint": "{message}\n{hint}",
"withSetupHint": "{message}\n提示:{hint}",
"blocked": {
"missingConfig": "無法讀取目前 Agent 設定。",
"disabled": "{agent} 已在 Agents 管理中停用,請先啟用後再連線。",
@@ -1195,7 +1202,7 @@
"streaming": "生成中",
"elapsedMinutes": "{value} 分鐘",
"elapsedSeconds": "{value} 秒",
"toolUseCount": "{count} 工具呼叫"
"toolUseCount": "{count} 工具 {count, plural, one {use} other {uses}}"
},
"tool": {
"parameters": "參數",
@@ -1243,14 +1250,14 @@
"nameLabel": "名稱:",
"field": {
"file": "檔案",
"notebook": "Notebook",
"notebook": "筆記本",
"command": "命令",
"old": "舊內容",
"new": "新內容",
"pattern": "模式",
"path": "路徑",
"query": "查詢",
"url": "URL",
"url": "URL 位址",
"description": "描述",
"content": "內容",
"source": "來源內容",

View File

@@ -1,11 +1,32 @@
import type { AppLocale, SystemLanguageSettings } from "@/lib/types"
export const APP_LOCALES: readonly AppLocale[] = ["en", "zh_cn", "zh_tw"]
export const APP_LOCALES: readonly AppLocale[] = [
"en",
"zh_cn",
"zh_tw",
"ja",
"ko",
"es",
"de",
"fr",
"pt",
"ar",
]
const FALLBACK_APP_LOCALE: AppLocale = "en"
export const LANGUAGE_SETTINGS_STORAGE_KEY = "codeg.system_language_settings"
export const LANGUAGE_MODE_COOKIE_KEY = "codeg.language_mode"
export const LANGUAGE_COOKIE_KEY = "codeg.locale"
export type IntlLocale = "en" | "zh-CN" | "zh-TW"
export type IntlLocale =
| "en"
| "zh-CN"
| "zh-TW"
| "ja"
| "ko"
| "es"
| "de"
| "fr"
| "pt"
| "ar"
export const DEFAULT_LANGUAGE_SETTINGS: SystemLanguageSettings = {
mode: "system",
@@ -16,12 +37,26 @@ export const APP_LOCALE_TO_INTL_LOCALE: Record<AppLocale, IntlLocale> = {
en: "en",
zh_cn: "zh-CN",
zh_tw: "zh-TW",
ja: "ja",
ko: "ko",
es: "es",
de: "de",
fr: "fr",
pt: "pt",
ar: "ar",
}
export const INTL_LOCALE_TO_APP_LOCALE: Record<IntlLocale, AppLocale> = {
en: "en",
"zh-CN": "zh_cn",
"zh-TW": "zh_tw",
ja: "ja",
ko: "ko",
es: "es",
de: "de",
fr: "fr",
pt: "pt",
ar: "ar",
}
export function isAppLocale(value: unknown): value is AppLocale {
@@ -29,7 +64,18 @@ export function isAppLocale(value: unknown): value is AppLocale {
}
export function isIntlLocale(value: unknown): value is IntlLocale {
return value === "en" || value === "zh-CN" || value === "zh-TW"
return (
value === "en" ||
value === "zh-CN" ||
value === "zh-TW" ||
value === "ja" ||
value === "ko" ||
value === "es" ||
value === "de" ||
value === "fr" ||
value === "pt" ||
value === "ar"
)
}
export function toIntlLocale(locale: AppLocale): IntlLocale {
@@ -70,6 +116,13 @@ export function mapLocaleTagToAppLocale(localeTag: string): AppLocale | null {
}
if (normalized.startsWith("zh")) return "zh_cn"
if (normalized.startsWith("ja")) return "ja"
if (normalized.startsWith("ko")) return "ko"
if (normalized.startsWith("es")) return "es"
if (normalized.startsWith("de")) return "de"
if (normalized.startsWith("fr")) return "fr"
if (normalized.startsWith("pt")) return "pt"
if (normalized.startsWith("ar")) return "ar"
return null
}

View File

@@ -554,7 +554,17 @@ export interface SystemProxySettings {
proxy_url: string | null
}
export type AppLocale = "en" | "zh_cn" | "zh_tw"
export type AppLocale =
| "en"
| "zh_cn"
| "zh_tw"
| "ja"
| "ko"
| "es"
| "de"
| "fr"
| "pt"
| "ar"
export type LanguageMode = "system" | "manual"
export interface SystemLanguageSettings {