fix(i18n): Auto update translations for PR #10170

This commit is contained in:
GitHub Action 2025-09-14 23:23:31 +00:00
parent 7d48bc5c5a
commit a7edd32efd
11 changed files with 39605 additions and 39581 deletions

View File

@ -1,55 +1,57 @@
import { loggerService } from '@logger'
import { defaultLanguage } from '@shared/config/constant'
import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import { loggerService } from "@logger";
import { defaultLanguage } from "@shared/config/constant";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
// Original translation
import enUS from './locales/en-us.json'
import zhCN from './locales/zh-cn.json'
import zhTW from './locales/zh-tw.json'
import enUS from "./locales/en-us.json";
import zhCN from "./locales/zh-cn.json";
import zhTW from "./locales/zh-tw.json";
// Machine translation
import elGR from './translate/el-gr.json'
import esES from './translate/es-es.json'
import frFR from './translate/fr-fr.json'
import jaJP from './translate/ja-jp.json'
import ptPT from './translate/pt-pt.json'
import ruRU from './translate/ru-ru.json'
import elGR from "./translate/el-gr.json";
import esES from "./translate/es-es.json";
import frFR from "./translate/fr-fr.json";
import jaJP from "./translate/ja-jp.json";
import ptPT from "./translate/pt-pt.json";
import ruRU from "./translate/ru-ru.json";
const logger = loggerService.withContext('I18N')
const logger = loggerService.withContext("I18N");
const resources = Object.fromEntries(
[
['en-US', enUS],
['ja-JP', jaJP],
['ru-RU', ruRU],
['zh-CN', zhCN],
['zh-TW', zhTW],
['el-GR', elGR],
['es-ES', esES],
['fr-FR', frFR],
['pt-PT', ptPT]
].map(([locale, translation]) => [locale, { translation }])
)
["en-US", enUS],
["ja-JP", jaJP],
["ru-RU", ruRU],
["zh-CN", zhCN],
["zh-TW", zhTW],
["el-GR", elGR],
["es-ES", esES],
["fr-FR", frFR],
["pt-PT", ptPT],
].map(([locale, translation]) => [locale, { translation }]),
);
export const getLanguage = () => {
return localStorage.getItem('language') || navigator.language || defaultLanguage
}
return (
localStorage.getItem("language") || navigator.language || defaultLanguage
);
};
export const getLanguageCode = () => {
return getLanguage().split('-')[0]
}
return getLanguage().split("-")[0];
};
i18n.use(initReactI18next).init({
resources,
lng: getLanguage(),
fallbackLng: defaultLanguage,
interpolation: {
escapeValue: false
escapeValue: false,
},
saveMissing: true,
missingKeyHandler: (_1, _2, key) => {
logger.error(`Missing key: ${key}`)
}
})
logger.error(`Missing key: ${key}`);
},
});
export default i18n
export default i18n;

View File

@ -4,84 +4,93 @@
* 2.
*/
import { loggerService } from '@logger'
import { BuiltinMCPServerName, BuiltinMCPServerNames, BuiltinOcrProviderId, ThinkingOption } from '@renderer/types'
import { loggerService } from "@logger";
import {
BuiltinMCPServerName,
BuiltinMCPServerNames,
BuiltinOcrProviderId,
ThinkingOption,
} from "@renderer/types";
import i18n from './index'
import i18n from "./index";
const t = i18n.t
const t = i18n.t;
const logger = loggerService.withContext('i18n:label')
const logger = loggerService.withContext("i18n:label");
const getLabel = (keyMap: Record<string, string>, key: string, fallback?: string) => {
const result = keyMap[key]
const getLabel = (
keyMap: Record<string, string>,
key: string,
fallback?: string,
) => {
const result = keyMap[key];
if (result) {
return t(result)
return t(result);
} else {
logger.error(`Missing key ${key}`)
return fallback ?? key
}
logger.error(`Missing key ${key}`);
return fallback ?? key;
}
};
const providerKeyMap = {
'302ai': 'provider.302ai',
aihubmix: 'provider.aihubmix',
alayanew: 'provider.alayanew',
anthropic: 'provider.anthropic',
'aws-bedrock': 'provider.aws-bedrock',
'azure-openai': 'provider.azure-openai',
baichuan: 'provider.baichuan',
'baidu-cloud': 'provider.baidu-cloud',
burncloud: 'provider.burncloud',
cephalon: 'provider.cephalon',
cherryin: 'provider.cherryin',
copilot: 'provider.copilot',
dashscope: 'provider.dashscope',
deepseek: 'provider.deepseek',
dmxapi: 'provider.dmxapi',
doubao: 'provider.doubao',
fireworks: 'provider.fireworks',
gemini: 'provider.gemini',
'gitee-ai': 'provider.gitee-ai',
github: 'provider.github',
gpustack: 'provider.gpustack',
grok: 'provider.grok',
groq: 'provider.groq',
hunyuan: 'provider.hunyuan',
hyperbolic: 'provider.hyperbolic',
infini: 'provider.infini',
jina: 'provider.jina',
lanyun: 'provider.lanyun',
lmstudio: 'provider.lmstudio',
minimax: 'provider.minimax',
mistral: 'provider.mistral',
modelscope: 'provider.modelscope',
moonshot: 'provider.moonshot',
'new-api': 'provider.new-api',
nvidia: 'provider.nvidia',
o3: 'provider.o3',
ocoolai: 'provider.ocoolai',
ollama: 'provider.ollama',
openai: 'provider.openai',
openrouter: 'provider.openrouter',
perplexity: 'provider.perplexity',
ph8: 'provider.ph8',
ppio: 'provider.ppio',
qiniu: 'provider.qiniu',
qwenlm: 'provider.qwenlm',
silicon: 'provider.silicon',
stepfun: 'provider.stepfun',
'tencent-cloud-ti': 'provider.tencent-cloud-ti',
together: 'provider.together',
tokenflux: 'provider.tokenflux',
vertexai: 'provider.vertexai',
voyageai: 'provider.voyageai',
xirang: 'provider.xirang',
yi: 'provider.yi',
zhinao: 'provider.zhinao',
zhipu: 'provider.zhipu',
poe: 'provider.poe'
} as const
"302ai": "provider.302ai",
aihubmix: "provider.aihubmix",
alayanew: "provider.alayanew",
anthropic: "provider.anthropic",
"aws-bedrock": "provider.aws-bedrock",
"azure-openai": "provider.azure-openai",
baichuan: "provider.baichuan",
"baidu-cloud": "provider.baidu-cloud",
burncloud: "provider.burncloud",
cephalon: "provider.cephalon",
cherryin: "provider.cherryin",
copilot: "provider.copilot",
dashscope: "provider.dashscope",
deepseek: "provider.deepseek",
dmxapi: "provider.dmxapi",
doubao: "provider.doubao",
fireworks: "provider.fireworks",
gemini: "provider.gemini",
"gitee-ai": "provider.gitee-ai",
github: "provider.github",
gpustack: "provider.gpustack",
grok: "provider.grok",
groq: "provider.groq",
hunyuan: "provider.hunyuan",
hyperbolic: "provider.hyperbolic",
infini: "provider.infini",
jina: "provider.jina",
lanyun: "provider.lanyun",
lmstudio: "provider.lmstudio",
minimax: "provider.minimax",
mistral: "provider.mistral",
modelscope: "provider.modelscope",
moonshot: "provider.moonshot",
"new-api": "provider.new-api",
nvidia: "provider.nvidia",
o3: "provider.o3",
ocoolai: "provider.ocoolai",
ollama: "provider.ollama",
openai: "provider.openai",
openrouter: "provider.openrouter",
perplexity: "provider.perplexity",
ph8: "provider.ph8",
ppio: "provider.ppio",
qiniu: "provider.qiniu",
qwenlm: "provider.qwenlm",
silicon: "provider.silicon",
stepfun: "provider.stepfun",
"tencent-cloud-ti": "provider.tencent-cloud-ti",
together: "provider.together",
tokenflux: "provider.tokenflux",
vertexai: "provider.vertexai",
voyageai: "provider.voyageai",
xirang: "provider.xirang",
yi: "provider.yi",
zhinao: "provider.zhinao",
zhipu: "provider.zhipu",
poe: "provider.poe",
} as const;
/**
*
@ -93,248 +102,261 @@ const providerKeyMap = {
* 使 getProviderName getFancyProviderName
*/
export const getProviderLabel = (id: string): string => {
return getLabel(providerKeyMap, id)
}
return getLabel(providerKeyMap, id);
};
const backupProgressKeyMap = {
completed: 'backup.progress.completed',
compressing: 'backup.progress.compressing',
copying_files: 'backup.progress.copying_files',
preparing_compression: 'backup.progress.preparing_compression',
preparing: 'backup.progress.preparing',
title: 'backup.progress.title',
writing_data: 'backup.progress.writing_data'
} as const
completed: "backup.progress.completed",
compressing: "backup.progress.compressing",
copying_files: "backup.progress.copying_files",
preparing_compression: "backup.progress.preparing_compression",
preparing: "backup.progress.preparing",
title: "backup.progress.title",
writing_data: "backup.progress.writing_data",
} as const;
export const getBackupProgressLabel = (key: string): string => {
return getLabel(backupProgressKeyMap, key)
}
return getLabel(backupProgressKeyMap, key);
};
const restoreProgressKeyMap = {
completed: 'restore.progress.completed',
copying_files: 'restore.progress.copying_files',
extracted: 'restore.progress.extracted',
extracting: 'restore.progress.extracting',
preparing: 'restore.progress.preparing',
reading_data: 'restore.progress.reading_data',
title: 'restore.progress.title'
}
completed: "restore.progress.completed",
copying_files: "restore.progress.copying_files",
extracted: "restore.progress.extracted",
extracting: "restore.progress.extracting",
preparing: "restore.progress.preparing",
reading_data: "restore.progress.reading_data",
title: "restore.progress.title",
};
export const getRestoreProgressLabel = (key: string): string => {
return getLabel(restoreProgressKeyMap, key)
}
return getLabel(restoreProgressKeyMap, key);
};
const titleKeyMap = {
agents: 'title.agents',
apps: 'title.apps',
code: 'title.code',
files: 'title.files',
home: 'title.home',
knowledge: 'title.knowledge',
launchpad: 'title.launchpad',
'mcp-servers': 'title.mcp-servers',
memories: 'title.memories',
notes: 'title.notes',
paintings: 'title.paintings',
settings: 'title.settings',
translate: 'title.translate'
} as const
agents: "title.agents",
apps: "title.apps",
code: "title.code",
files: "title.files",
home: "title.home",
knowledge: "title.knowledge",
launchpad: "title.launchpad",
"mcp-servers": "title.mcp-servers",
memories: "title.memories",
notes: "title.notes",
paintings: "title.paintings",
settings: "title.settings",
translate: "title.translate",
} as const;
export const getTitleLabel = (key: string): string => {
return getLabel(titleKeyMap, key)
}
return getLabel(titleKeyMap, key);
};
const themeModeKeyMap = {
dark: 'settings.theme.dark',
light: 'settings.theme.light',
system: 'settings.theme.system'
} as const
dark: "settings.theme.dark",
light: "settings.theme.light",
system: "settings.theme.system",
} as const;
export const getThemeModeLabel = (key: string): string => {
return getLabel(themeModeKeyMap, key)
}
return getLabel(themeModeKeyMap, key);
};
const sidebarIconKeyMap = {
assistants: 'assistants.title',
agents: 'agents.title',
paintings: 'paintings.title',
translate: 'translate.title',
minapp: 'minapp.title',
knowledge: 'knowledge.title',
files: 'files.title',
code_tools: 'code.title',
notes: 'notes.title'
} as const
assistants: "assistants.title",
agents: "agents.title",
paintings: "paintings.title",
translate: "translate.title",
minapp: "minapp.title",
knowledge: "knowledge.title",
files: "files.title",
code_tools: "code.title",
notes: "notes.title",
} as const;
export const getSidebarIconLabel = (key: string): string => {
return getLabel(sidebarIconKeyMap, key)
}
return getLabel(sidebarIconKeyMap, key);
};
const shortcutKeyMap = {
action: 'settings.shortcuts.action',
actions: 'settings.shortcuts.actions',
clear_shortcut: 'settings.shortcuts.clear_shortcut',
clear_topic: 'settings.shortcuts.clear_topic',
rename_topic: 'settings.shortcuts.rename_topic',
copy_last_message: 'settings.shortcuts.copy_last_message',
edit_last_user_message: 'settings.shortcuts.edit_last_user_message',
enabled: 'settings.shortcuts.enabled',
exit_fullscreen: 'settings.shortcuts.exit_fullscreen',
label: 'settings.shortcuts.label',
mini_window: 'settings.shortcuts.mini_window',
new_topic: 'settings.shortcuts.new_topic',
press_shortcut: 'settings.shortcuts.press_shortcut',
reset_defaults: 'settings.shortcuts.reset_defaults',
reset_defaults_confirm: 'settings.shortcuts.reset_defaults_confirm',
reset_to_default: 'settings.shortcuts.reset_to_default',
search_message: 'settings.shortcuts.search_message',
search_message_in_chat: 'settings.shortcuts.search_message_in_chat',
selection_assistant_select_text: 'settings.shortcuts.selection_assistant_select_text',
selection_assistant_toggle: 'settings.shortcuts.selection_assistant_toggle',
show_app: 'settings.shortcuts.show_app',
show_settings: 'settings.shortcuts.show_settings',
title: 'settings.shortcuts.title',
toggle_new_context: 'settings.shortcuts.toggle_new_context',
toggle_show_assistants: 'settings.shortcuts.toggle_show_assistants',
toggle_show_topics: 'settings.shortcuts.toggle_show_topics',
zoom_in: 'settings.shortcuts.zoom_in',
zoom_out: 'settings.shortcuts.zoom_out',
zoom_reset: 'settings.shortcuts.zoom_reset'
} as const
action: "settings.shortcuts.action",
actions: "settings.shortcuts.actions",
clear_shortcut: "settings.shortcuts.clear_shortcut",
clear_topic: "settings.shortcuts.clear_topic",
rename_topic: "settings.shortcuts.rename_topic",
copy_last_message: "settings.shortcuts.copy_last_message",
edit_last_user_message: "settings.shortcuts.edit_last_user_message",
enabled: "settings.shortcuts.enabled",
exit_fullscreen: "settings.shortcuts.exit_fullscreen",
label: "settings.shortcuts.label",
mini_window: "settings.shortcuts.mini_window",
new_topic: "settings.shortcuts.new_topic",
press_shortcut: "settings.shortcuts.press_shortcut",
reset_defaults: "settings.shortcuts.reset_defaults",
reset_defaults_confirm: "settings.shortcuts.reset_defaults_confirm",
reset_to_default: "settings.shortcuts.reset_to_default",
search_message: "settings.shortcuts.search_message",
search_message_in_chat: "settings.shortcuts.search_message_in_chat",
selection_assistant_select_text:
"settings.shortcuts.selection_assistant_select_text",
selection_assistant_toggle: "settings.shortcuts.selection_assistant_toggle",
show_app: "settings.shortcuts.show_app",
show_settings: "settings.shortcuts.show_settings",
title: "settings.shortcuts.title",
toggle_new_context: "settings.shortcuts.toggle_new_context",
toggle_show_assistants: "settings.shortcuts.toggle_show_assistants",
toggle_show_topics: "settings.shortcuts.toggle_show_topics",
zoom_in: "settings.shortcuts.zoom_in",
zoom_out: "settings.shortcuts.zoom_out",
zoom_reset: "settings.shortcuts.zoom_reset",
} as const;
export const getShortcutLabel = (key: string): string => {
return getLabel(shortcutKeyMap, key)
}
return getLabel(shortcutKeyMap, key);
};
const selectionDescriptionKeyMap = {
mac: 'selection.settings.toolbar.trigger_mode.description_note.mac',
windows: 'selection.settings.toolbar.trigger_mode.description_note.windows'
} as const
mac: "selection.settings.toolbar.trigger_mode.description_note.mac",
windows: "selection.settings.toolbar.trigger_mode.description_note.windows",
} as const;
export const getSelectionDescriptionLabel = (key: string): string => {
return getLabel(selectionDescriptionKeyMap, key)
}
return getLabel(selectionDescriptionKeyMap, key);
};
const paintingsImageSizeOptionsKeyMap = {
auto: 'paintings.image_size_options.auto'
} as const
auto: "paintings.image_size_options.auto",
} as const;
export const getPaintingsImageSizeOptionsLabel = (key: string): string => {
return getLabel(paintingsImageSizeOptionsKeyMap, key)
}
return getLabel(paintingsImageSizeOptionsKeyMap, key);
};
const paintingsQualityOptionsKeyMap = {
auto: 'paintings.quality_options.auto',
high: 'paintings.quality_options.high',
low: 'paintings.quality_options.low',
medium: 'paintings.quality_options.medium'
} as const
auto: "paintings.quality_options.auto",
high: "paintings.quality_options.high",
low: "paintings.quality_options.low",
medium: "paintings.quality_options.medium",
} as const;
export const getPaintingsQualityOptionsLabel = (key: string): string => {
return getLabel(paintingsQualityOptionsKeyMap, key)
}
return getLabel(paintingsQualityOptionsKeyMap, key);
};
const paintingsModerationOptionsKeyMap = {
auto: 'paintings.moderation_options.auto',
low: 'paintings.moderation_options.low'
} as const
auto: "paintings.moderation_options.auto",
low: "paintings.moderation_options.low",
} as const;
export const getPaintingsModerationOptionsLabel = (key: string): string => {
return getLabel(paintingsModerationOptionsKeyMap, key)
}
return getLabel(paintingsModerationOptionsKeyMap, key);
};
const paintingsBackgroundOptionsKeyMap = {
auto: 'paintings.background_options.auto',
opaque: 'paintings.background_options.opaque',
transparent: 'paintings.background_options.transparent'
} as const
auto: "paintings.background_options.auto",
opaque: "paintings.background_options.opaque",
transparent: "paintings.background_options.transparent",
} as const;
export const getPaintingsBackgroundOptionsLabel = (key: string): string => {
return getLabel(paintingsBackgroundOptionsKeyMap, key)
}
return getLabel(paintingsBackgroundOptionsKeyMap, key);
};
const mcpTypeKeyMap = {
inMemory: 'settings.mcp.types.inMemory',
sse: 'settings.mcp.types.sse',
stdio: 'settings.mcp.types.stdio',
streamableHttp: 'settings.mcp.types.streamableHttp'
} as const
inMemory: "settings.mcp.types.inMemory",
sse: "settings.mcp.types.sse",
stdio: "settings.mcp.types.stdio",
streamableHttp: "settings.mcp.types.streamableHttp",
} as const;
export const getMcpTypeLabel = (key: string): string => {
return getLabel(mcpTypeKeyMap, key)
}
return getLabel(mcpTypeKeyMap, key);
};
const miniappsStatusKeyMap = {
visible: 'settings.miniapps.visible',
disabled: 'settings.miniapps.disabled'
} as const
visible: "settings.miniapps.visible",
disabled: "settings.miniapps.disabled",
} as const;
export const getMiniappsStatusLabel = (key: string): string => {
return getLabel(miniappsStatusKeyMap, key)
}
return getLabel(miniappsStatusKeyMap, key);
};
const httpMessageKeyMap = {
'400': 'error.http.400',
'401': 'error.http.401',
'403': 'error.http.403',
'404': 'error.http.404',
'429': 'error.http.429',
'500': 'error.http.500',
'502': 'error.http.502',
'503': 'error.http.503',
'504': 'error.http.504'
} as const
"400": "error.http.400",
"401": "error.http.401",
"403": "error.http.403",
"404": "error.http.404",
"429": "error.http.429",
"500": "error.http.500",
"502": "error.http.502",
"503": "error.http.503",
"504": "error.http.504",
} as const;
export const getHttpMessageLabel = (key: string): string => {
return getLabel(httpMessageKeyMap, key)
}
return getLabel(httpMessageKeyMap, key);
};
const reasoningEffortOptionsKeyMap: Record<ThinkingOption, string> = {
off: 'assistants.settings.reasoning_effort.off',
minimal: 'assistants.settings.reasoning_effort.minimal',
high: 'assistants.settings.reasoning_effort.high',
low: 'assistants.settings.reasoning_effort.low',
medium: 'assistants.settings.reasoning_effort.medium',
auto: 'assistants.settings.reasoning_effort.default'
} as const
off: "assistants.settings.reasoning_effort.off",
minimal: "assistants.settings.reasoning_effort.minimal",
high: "assistants.settings.reasoning_effort.high",
low: "assistants.settings.reasoning_effort.low",
medium: "assistants.settings.reasoning_effort.medium",
auto: "assistants.settings.reasoning_effort.default",
} as const;
export const getReasoningEffortOptionsLabel = (key: string): string => {
return getLabel(reasoningEffortOptionsKeyMap, key)
}
return getLabel(reasoningEffortOptionsKeyMap, key);
};
const fileFieldKeyMap = {
created_at: 'files.created_at',
size: 'files.size',
name: 'files.name'
} as const
created_at: "files.created_at",
size: "files.size",
name: "files.name",
} as const;
export const getFileFieldLabel = (key: string): string => {
return getLabel(fileFieldKeyMap, key)
}
return getLabel(fileFieldKeyMap, key);
};
const builtInMcpDescriptionKeyMap: Record<BuiltinMCPServerName, string> = {
[BuiltinMCPServerNames.mcpAutoInstall]: 'settings.mcp.builtinServersDescriptions.mcp_auto_install',
[BuiltinMCPServerNames.memory]: 'settings.mcp.builtinServersDescriptions.memory',
[BuiltinMCPServerNames.sequentialThinking]: 'settings.mcp.builtinServersDescriptions.sequentialthinking',
[BuiltinMCPServerNames.braveSearch]: 'settings.mcp.builtinServersDescriptions.brave_search',
[BuiltinMCPServerNames.fetch]: 'settings.mcp.builtinServersDescriptions.fetch',
[BuiltinMCPServerNames.filesystem]: 'settings.mcp.builtinServersDescriptions.filesystem',
[BuiltinMCPServerNames.difyKnowledge]: 'settings.mcp.builtinServersDescriptions.dify_knowledge',
[BuiltinMCPServerNames.python]: 'settings.mcp.builtinServersDescriptions.python'
} as const
[BuiltinMCPServerNames.mcpAutoInstall]:
"settings.mcp.builtinServersDescriptions.mcp_auto_install",
[BuiltinMCPServerNames.memory]:
"settings.mcp.builtinServersDescriptions.memory",
[BuiltinMCPServerNames.sequentialThinking]:
"settings.mcp.builtinServersDescriptions.sequentialthinking",
[BuiltinMCPServerNames.braveSearch]:
"settings.mcp.builtinServersDescriptions.brave_search",
[BuiltinMCPServerNames.fetch]:
"settings.mcp.builtinServersDescriptions.fetch",
[BuiltinMCPServerNames.filesystem]:
"settings.mcp.builtinServersDescriptions.filesystem",
[BuiltinMCPServerNames.difyKnowledge]:
"settings.mcp.builtinServersDescriptions.dify_knowledge",
[BuiltinMCPServerNames.python]:
"settings.mcp.builtinServersDescriptions.python",
} as const;
export const getBuiltInMcpServerDescriptionLabel = (key: string): string => {
return getLabel(builtInMcpDescriptionKeyMap, key, t('settings.mcp.builtinServersDescriptions.no'))
}
return getLabel(
builtInMcpDescriptionKeyMap,
key,
t("settings.mcp.builtinServersDescriptions.no"),
);
};
const builtinOcrProviderKeyMap = {
system: 'ocr.builtin.system',
tesseract: '',
paddleocr: ''
} as const satisfies Record<BuiltinOcrProviderId, string>
system: "ocr.builtin.system",
tesseract: "",
paddleocr: "",
} as const satisfies Record<BuiltinOcrProviderId, string>;
export const getBuiltinOcrProviderLabel = (key: BuiltinOcrProviderId) => {
if (key === 'tesseract') return 'Tesseract'
else if (key == 'paddleocr') return 'PaddleOCR'
else return getLabel(builtinOcrProviderKeyMap, key)
}
if (key === "tesseract") return "Tesseract";
else if (key == "paddleocr") return "PaddleOCR";
else return getLabel(builtinOcrProviderKeyMap, key);
};