mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-20 23:22:05 +08:00
fix(i18n): Auto update translations for PR #10170
This commit is contained in:
parent
7d48bc5c5a
commit
a7edd32efd
@ -1,55 +1,57 @@
|
|||||||
import { loggerService } from '@logger'
|
import { loggerService } from "@logger";
|
||||||
import { defaultLanguage } from '@shared/config/constant'
|
import { defaultLanguage } from "@shared/config/constant";
|
||||||
import i18n from 'i18next'
|
import i18n from "i18next";
|
||||||
import { initReactI18next } from 'react-i18next'
|
import { initReactI18next } from "react-i18next";
|
||||||
|
|
||||||
// Original translation
|
// Original translation
|
||||||
import enUS from './locales/en-us.json'
|
import enUS from "./locales/en-us.json";
|
||||||
import zhCN from './locales/zh-cn.json'
|
import zhCN from "./locales/zh-cn.json";
|
||||||
import zhTW from './locales/zh-tw.json'
|
import zhTW from "./locales/zh-tw.json";
|
||||||
// Machine translation
|
// Machine translation
|
||||||
import elGR from './translate/el-gr.json'
|
import elGR from "./translate/el-gr.json";
|
||||||
import esES from './translate/es-es.json'
|
import esES from "./translate/es-es.json";
|
||||||
import frFR from './translate/fr-fr.json'
|
import frFR from "./translate/fr-fr.json";
|
||||||
import jaJP from './translate/ja-jp.json'
|
import jaJP from "./translate/ja-jp.json";
|
||||||
import ptPT from './translate/pt-pt.json'
|
import ptPT from "./translate/pt-pt.json";
|
||||||
import ruRU from './translate/ru-ru.json'
|
import ruRU from "./translate/ru-ru.json";
|
||||||
|
|
||||||
const logger = loggerService.withContext('I18N')
|
const logger = loggerService.withContext("I18N");
|
||||||
|
|
||||||
const resources = Object.fromEntries(
|
const resources = Object.fromEntries(
|
||||||
[
|
[
|
||||||
['en-US', enUS],
|
["en-US", enUS],
|
||||||
['ja-JP', jaJP],
|
["ja-JP", jaJP],
|
||||||
['ru-RU', ruRU],
|
["ru-RU", ruRU],
|
||||||
['zh-CN', zhCN],
|
["zh-CN", zhCN],
|
||||||
['zh-TW', zhTW],
|
["zh-TW", zhTW],
|
||||||
['el-GR', elGR],
|
["el-GR", elGR],
|
||||||
['es-ES', esES],
|
["es-ES", esES],
|
||||||
['fr-FR', frFR],
|
["fr-FR", frFR],
|
||||||
['pt-PT', ptPT]
|
["pt-PT", ptPT],
|
||||||
].map(([locale, translation]) => [locale, { translation }])
|
].map(([locale, translation]) => [locale, { translation }]),
|
||||||
)
|
);
|
||||||
|
|
||||||
export const getLanguage = () => {
|
export const getLanguage = () => {
|
||||||
return localStorage.getItem('language') || navigator.language || defaultLanguage
|
return (
|
||||||
}
|
localStorage.getItem("language") || navigator.language || defaultLanguage
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const getLanguageCode = () => {
|
export const getLanguageCode = () => {
|
||||||
return getLanguage().split('-')[0]
|
return getLanguage().split("-")[0];
|
||||||
}
|
};
|
||||||
|
|
||||||
i18n.use(initReactI18next).init({
|
i18n.use(initReactI18next).init({
|
||||||
resources,
|
resources,
|
||||||
lng: getLanguage(),
|
lng: getLanguage(),
|
||||||
fallbackLng: defaultLanguage,
|
fallbackLng: defaultLanguage,
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false
|
escapeValue: false,
|
||||||
},
|
},
|
||||||
saveMissing: true,
|
saveMissing: true,
|
||||||
missingKeyHandler: (_1, _2, key) => {
|
missingKeyHandler: (_1, _2, key) => {
|
||||||
logger.error(`Missing key: ${key}`)
|
logger.error(`Missing key: ${key}`);
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
export default i18n
|
export default i18n;
|
||||||
|
|||||||
@ -4,84 +4,93 @@
|
|||||||
* 2. 通过函数翻译文本
|
* 2. 通过函数翻译文本
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loggerService } from '@logger'
|
import { loggerService } from "@logger";
|
||||||
import { BuiltinMCPServerName, BuiltinMCPServerNames, BuiltinOcrProviderId, ThinkingOption } from '@renderer/types'
|
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 getLabel = (
|
||||||
const result = keyMap[key]
|
keyMap: Record<string, string>,
|
||||||
if (result) {
|
key: string,
|
||||||
return t(result)
|
fallback?: string,
|
||||||
} else {
|
) => {
|
||||||
logger.error(`Missing key ${key}`)
|
const result = keyMap[key];
|
||||||
return fallback ?? key
|
if (result) {
|
||||||
}
|
return t(result);
|
||||||
}
|
} else {
|
||||||
|
logger.error(`Missing key ${key}`);
|
||||||
|
return fallback ?? key;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const providerKeyMap = {
|
const providerKeyMap = {
|
||||||
'302ai': 'provider.302ai',
|
"302ai": "provider.302ai",
|
||||||
aihubmix: 'provider.aihubmix',
|
aihubmix: "provider.aihubmix",
|
||||||
alayanew: 'provider.alayanew',
|
alayanew: "provider.alayanew",
|
||||||
anthropic: 'provider.anthropic',
|
anthropic: "provider.anthropic",
|
||||||
'aws-bedrock': 'provider.aws-bedrock',
|
"aws-bedrock": "provider.aws-bedrock",
|
||||||
'azure-openai': 'provider.azure-openai',
|
"azure-openai": "provider.azure-openai",
|
||||||
baichuan: 'provider.baichuan',
|
baichuan: "provider.baichuan",
|
||||||
'baidu-cloud': 'provider.baidu-cloud',
|
"baidu-cloud": "provider.baidu-cloud",
|
||||||
burncloud: 'provider.burncloud',
|
burncloud: "provider.burncloud",
|
||||||
cephalon: 'provider.cephalon',
|
cephalon: "provider.cephalon",
|
||||||
cherryin: 'provider.cherryin',
|
cherryin: "provider.cherryin",
|
||||||
copilot: 'provider.copilot',
|
copilot: "provider.copilot",
|
||||||
dashscope: 'provider.dashscope',
|
dashscope: "provider.dashscope",
|
||||||
deepseek: 'provider.deepseek',
|
deepseek: "provider.deepseek",
|
||||||
dmxapi: 'provider.dmxapi',
|
dmxapi: "provider.dmxapi",
|
||||||
doubao: 'provider.doubao',
|
doubao: "provider.doubao",
|
||||||
fireworks: 'provider.fireworks',
|
fireworks: "provider.fireworks",
|
||||||
gemini: 'provider.gemini',
|
gemini: "provider.gemini",
|
||||||
'gitee-ai': 'provider.gitee-ai',
|
"gitee-ai": "provider.gitee-ai",
|
||||||
github: 'provider.github',
|
github: "provider.github",
|
||||||
gpustack: 'provider.gpustack',
|
gpustack: "provider.gpustack",
|
||||||
grok: 'provider.grok',
|
grok: "provider.grok",
|
||||||
groq: 'provider.groq',
|
groq: "provider.groq",
|
||||||
hunyuan: 'provider.hunyuan',
|
hunyuan: "provider.hunyuan",
|
||||||
hyperbolic: 'provider.hyperbolic',
|
hyperbolic: "provider.hyperbolic",
|
||||||
infini: 'provider.infini',
|
infini: "provider.infini",
|
||||||
jina: 'provider.jina',
|
jina: "provider.jina",
|
||||||
lanyun: 'provider.lanyun',
|
lanyun: "provider.lanyun",
|
||||||
lmstudio: 'provider.lmstudio',
|
lmstudio: "provider.lmstudio",
|
||||||
minimax: 'provider.minimax',
|
minimax: "provider.minimax",
|
||||||
mistral: 'provider.mistral',
|
mistral: "provider.mistral",
|
||||||
modelscope: 'provider.modelscope',
|
modelscope: "provider.modelscope",
|
||||||
moonshot: 'provider.moonshot',
|
moonshot: "provider.moonshot",
|
||||||
'new-api': 'provider.new-api',
|
"new-api": "provider.new-api",
|
||||||
nvidia: 'provider.nvidia',
|
nvidia: "provider.nvidia",
|
||||||
o3: 'provider.o3',
|
o3: "provider.o3",
|
||||||
ocoolai: 'provider.ocoolai',
|
ocoolai: "provider.ocoolai",
|
||||||
ollama: 'provider.ollama',
|
ollama: "provider.ollama",
|
||||||
openai: 'provider.openai',
|
openai: "provider.openai",
|
||||||
openrouter: 'provider.openrouter',
|
openrouter: "provider.openrouter",
|
||||||
perplexity: 'provider.perplexity',
|
perplexity: "provider.perplexity",
|
||||||
ph8: 'provider.ph8',
|
ph8: "provider.ph8",
|
||||||
ppio: 'provider.ppio',
|
ppio: "provider.ppio",
|
||||||
qiniu: 'provider.qiniu',
|
qiniu: "provider.qiniu",
|
||||||
qwenlm: 'provider.qwenlm',
|
qwenlm: "provider.qwenlm",
|
||||||
silicon: 'provider.silicon',
|
silicon: "provider.silicon",
|
||||||
stepfun: 'provider.stepfun',
|
stepfun: "provider.stepfun",
|
||||||
'tencent-cloud-ti': 'provider.tencent-cloud-ti',
|
"tencent-cloud-ti": "provider.tencent-cloud-ti",
|
||||||
together: 'provider.together',
|
together: "provider.together",
|
||||||
tokenflux: 'provider.tokenflux',
|
tokenflux: "provider.tokenflux",
|
||||||
vertexai: 'provider.vertexai',
|
vertexai: "provider.vertexai",
|
||||||
voyageai: 'provider.voyageai',
|
voyageai: "provider.voyageai",
|
||||||
xirang: 'provider.xirang',
|
xirang: "provider.xirang",
|
||||||
yi: 'provider.yi',
|
yi: "provider.yi",
|
||||||
zhinao: 'provider.zhinao',
|
zhinao: "provider.zhinao",
|
||||||
zhipu: 'provider.zhipu',
|
zhipu: "provider.zhipu",
|
||||||
poe: 'provider.poe'
|
poe: "provider.poe",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取内置供应商的本地化标签
|
* 获取内置供应商的本地化标签
|
||||||
@ -93,248 +102,261 @@ const providerKeyMap = {
|
|||||||
* 对于可能处理自定义供应商的情况,使用 getProviderName 或 getFancyProviderName 更安全
|
* 对于可能处理自定义供应商的情况,使用 getProviderName 或 getFancyProviderName 更安全
|
||||||
*/
|
*/
|
||||||
export const getProviderLabel = (id: string): string => {
|
export const getProviderLabel = (id: string): string => {
|
||||||
return getLabel(providerKeyMap, id)
|
return getLabel(providerKeyMap, id);
|
||||||
}
|
};
|
||||||
|
|
||||||
const backupProgressKeyMap = {
|
const backupProgressKeyMap = {
|
||||||
completed: 'backup.progress.completed',
|
completed: "backup.progress.completed",
|
||||||
compressing: 'backup.progress.compressing',
|
compressing: "backup.progress.compressing",
|
||||||
copying_files: 'backup.progress.copying_files',
|
copying_files: "backup.progress.copying_files",
|
||||||
preparing_compression: 'backup.progress.preparing_compression',
|
preparing_compression: "backup.progress.preparing_compression",
|
||||||
preparing: 'backup.progress.preparing',
|
preparing: "backup.progress.preparing",
|
||||||
title: 'backup.progress.title',
|
title: "backup.progress.title",
|
||||||
writing_data: 'backup.progress.writing_data'
|
writing_data: "backup.progress.writing_data",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getBackupProgressLabel = (key: string): string => {
|
export const getBackupProgressLabel = (key: string): string => {
|
||||||
return getLabel(backupProgressKeyMap, key)
|
return getLabel(backupProgressKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const restoreProgressKeyMap = {
|
const restoreProgressKeyMap = {
|
||||||
completed: 'restore.progress.completed',
|
completed: "restore.progress.completed",
|
||||||
copying_files: 'restore.progress.copying_files',
|
copying_files: "restore.progress.copying_files",
|
||||||
extracted: 'restore.progress.extracted',
|
extracted: "restore.progress.extracted",
|
||||||
extracting: 'restore.progress.extracting',
|
extracting: "restore.progress.extracting",
|
||||||
preparing: 'restore.progress.preparing',
|
preparing: "restore.progress.preparing",
|
||||||
reading_data: 'restore.progress.reading_data',
|
reading_data: "restore.progress.reading_data",
|
||||||
title: 'restore.progress.title'
|
title: "restore.progress.title",
|
||||||
}
|
};
|
||||||
|
|
||||||
export const getRestoreProgressLabel = (key: string): string => {
|
export const getRestoreProgressLabel = (key: string): string => {
|
||||||
return getLabel(restoreProgressKeyMap, key)
|
return getLabel(restoreProgressKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const titleKeyMap = {
|
const titleKeyMap = {
|
||||||
agents: 'title.agents',
|
agents: "title.agents",
|
||||||
apps: 'title.apps',
|
apps: "title.apps",
|
||||||
code: 'title.code',
|
code: "title.code",
|
||||||
files: 'title.files',
|
files: "title.files",
|
||||||
home: 'title.home',
|
home: "title.home",
|
||||||
knowledge: 'title.knowledge',
|
knowledge: "title.knowledge",
|
||||||
launchpad: 'title.launchpad',
|
launchpad: "title.launchpad",
|
||||||
'mcp-servers': 'title.mcp-servers',
|
"mcp-servers": "title.mcp-servers",
|
||||||
memories: 'title.memories',
|
memories: "title.memories",
|
||||||
notes: 'title.notes',
|
notes: "title.notes",
|
||||||
paintings: 'title.paintings',
|
paintings: "title.paintings",
|
||||||
settings: 'title.settings',
|
settings: "title.settings",
|
||||||
translate: 'title.translate'
|
translate: "title.translate",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getTitleLabel = (key: string): string => {
|
export const getTitleLabel = (key: string): string => {
|
||||||
return getLabel(titleKeyMap, key)
|
return getLabel(titleKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const themeModeKeyMap = {
|
const themeModeKeyMap = {
|
||||||
dark: 'settings.theme.dark',
|
dark: "settings.theme.dark",
|
||||||
light: 'settings.theme.light',
|
light: "settings.theme.light",
|
||||||
system: 'settings.theme.system'
|
system: "settings.theme.system",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getThemeModeLabel = (key: string): string => {
|
export const getThemeModeLabel = (key: string): string => {
|
||||||
return getLabel(themeModeKeyMap, key)
|
return getLabel(themeModeKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const sidebarIconKeyMap = {
|
const sidebarIconKeyMap = {
|
||||||
assistants: 'assistants.title',
|
assistants: "assistants.title",
|
||||||
agents: 'agents.title',
|
agents: "agents.title",
|
||||||
paintings: 'paintings.title',
|
paintings: "paintings.title",
|
||||||
translate: 'translate.title',
|
translate: "translate.title",
|
||||||
minapp: 'minapp.title',
|
minapp: "minapp.title",
|
||||||
knowledge: 'knowledge.title',
|
knowledge: "knowledge.title",
|
||||||
files: 'files.title',
|
files: "files.title",
|
||||||
code_tools: 'code.title',
|
code_tools: "code.title",
|
||||||
notes: 'notes.title'
|
notes: "notes.title",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getSidebarIconLabel = (key: string): string => {
|
export const getSidebarIconLabel = (key: string): string => {
|
||||||
return getLabel(sidebarIconKeyMap, key)
|
return getLabel(sidebarIconKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const shortcutKeyMap = {
|
const shortcutKeyMap = {
|
||||||
action: 'settings.shortcuts.action',
|
action: "settings.shortcuts.action",
|
||||||
actions: 'settings.shortcuts.actions',
|
actions: "settings.shortcuts.actions",
|
||||||
clear_shortcut: 'settings.shortcuts.clear_shortcut',
|
clear_shortcut: "settings.shortcuts.clear_shortcut",
|
||||||
clear_topic: 'settings.shortcuts.clear_topic',
|
clear_topic: "settings.shortcuts.clear_topic",
|
||||||
rename_topic: 'settings.shortcuts.rename_topic',
|
rename_topic: "settings.shortcuts.rename_topic",
|
||||||
copy_last_message: 'settings.shortcuts.copy_last_message',
|
copy_last_message: "settings.shortcuts.copy_last_message",
|
||||||
edit_last_user_message: 'settings.shortcuts.edit_last_user_message',
|
edit_last_user_message: "settings.shortcuts.edit_last_user_message",
|
||||||
enabled: 'settings.shortcuts.enabled',
|
enabled: "settings.shortcuts.enabled",
|
||||||
exit_fullscreen: 'settings.shortcuts.exit_fullscreen',
|
exit_fullscreen: "settings.shortcuts.exit_fullscreen",
|
||||||
label: 'settings.shortcuts.label',
|
label: "settings.shortcuts.label",
|
||||||
mini_window: 'settings.shortcuts.mini_window',
|
mini_window: "settings.shortcuts.mini_window",
|
||||||
new_topic: 'settings.shortcuts.new_topic',
|
new_topic: "settings.shortcuts.new_topic",
|
||||||
press_shortcut: 'settings.shortcuts.press_shortcut',
|
press_shortcut: "settings.shortcuts.press_shortcut",
|
||||||
reset_defaults: 'settings.shortcuts.reset_defaults',
|
reset_defaults: "settings.shortcuts.reset_defaults",
|
||||||
reset_defaults_confirm: 'settings.shortcuts.reset_defaults_confirm',
|
reset_defaults_confirm: "settings.shortcuts.reset_defaults_confirm",
|
||||||
reset_to_default: 'settings.shortcuts.reset_to_default',
|
reset_to_default: "settings.shortcuts.reset_to_default",
|
||||||
search_message: 'settings.shortcuts.search_message',
|
search_message: "settings.shortcuts.search_message",
|
||||||
search_message_in_chat: 'settings.shortcuts.search_message_in_chat',
|
search_message_in_chat: "settings.shortcuts.search_message_in_chat",
|
||||||
selection_assistant_select_text: 'settings.shortcuts.selection_assistant_select_text',
|
selection_assistant_select_text:
|
||||||
selection_assistant_toggle: 'settings.shortcuts.selection_assistant_toggle',
|
"settings.shortcuts.selection_assistant_select_text",
|
||||||
show_app: 'settings.shortcuts.show_app',
|
selection_assistant_toggle: "settings.shortcuts.selection_assistant_toggle",
|
||||||
show_settings: 'settings.shortcuts.show_settings',
|
show_app: "settings.shortcuts.show_app",
|
||||||
title: 'settings.shortcuts.title',
|
show_settings: "settings.shortcuts.show_settings",
|
||||||
toggle_new_context: 'settings.shortcuts.toggle_new_context',
|
title: "settings.shortcuts.title",
|
||||||
toggle_show_assistants: 'settings.shortcuts.toggle_show_assistants',
|
toggle_new_context: "settings.shortcuts.toggle_new_context",
|
||||||
toggle_show_topics: 'settings.shortcuts.toggle_show_topics',
|
toggle_show_assistants: "settings.shortcuts.toggle_show_assistants",
|
||||||
zoom_in: 'settings.shortcuts.zoom_in',
|
toggle_show_topics: "settings.shortcuts.toggle_show_topics",
|
||||||
zoom_out: 'settings.shortcuts.zoom_out',
|
zoom_in: "settings.shortcuts.zoom_in",
|
||||||
zoom_reset: 'settings.shortcuts.zoom_reset'
|
zoom_out: "settings.shortcuts.zoom_out",
|
||||||
} as const
|
zoom_reset: "settings.shortcuts.zoom_reset",
|
||||||
|
} as const;
|
||||||
|
|
||||||
export const getShortcutLabel = (key: string): string => {
|
export const getShortcutLabel = (key: string): string => {
|
||||||
return getLabel(shortcutKeyMap, key)
|
return getLabel(shortcutKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const selectionDescriptionKeyMap = {
|
const selectionDescriptionKeyMap = {
|
||||||
mac: 'selection.settings.toolbar.trigger_mode.description_note.mac',
|
mac: "selection.settings.toolbar.trigger_mode.description_note.mac",
|
||||||
windows: 'selection.settings.toolbar.trigger_mode.description_note.windows'
|
windows: "selection.settings.toolbar.trigger_mode.description_note.windows",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getSelectionDescriptionLabel = (key: string): string => {
|
export const getSelectionDescriptionLabel = (key: string): string => {
|
||||||
return getLabel(selectionDescriptionKeyMap, key)
|
return getLabel(selectionDescriptionKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const paintingsImageSizeOptionsKeyMap = {
|
const paintingsImageSizeOptionsKeyMap = {
|
||||||
auto: 'paintings.image_size_options.auto'
|
auto: "paintings.image_size_options.auto",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getPaintingsImageSizeOptionsLabel = (key: string): string => {
|
export const getPaintingsImageSizeOptionsLabel = (key: string): string => {
|
||||||
return getLabel(paintingsImageSizeOptionsKeyMap, key)
|
return getLabel(paintingsImageSizeOptionsKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const paintingsQualityOptionsKeyMap = {
|
const paintingsQualityOptionsKeyMap = {
|
||||||
auto: 'paintings.quality_options.auto',
|
auto: "paintings.quality_options.auto",
|
||||||
high: 'paintings.quality_options.high',
|
high: "paintings.quality_options.high",
|
||||||
low: 'paintings.quality_options.low',
|
low: "paintings.quality_options.low",
|
||||||
medium: 'paintings.quality_options.medium'
|
medium: "paintings.quality_options.medium",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getPaintingsQualityOptionsLabel = (key: string): string => {
|
export const getPaintingsQualityOptionsLabel = (key: string): string => {
|
||||||
return getLabel(paintingsQualityOptionsKeyMap, key)
|
return getLabel(paintingsQualityOptionsKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const paintingsModerationOptionsKeyMap = {
|
const paintingsModerationOptionsKeyMap = {
|
||||||
auto: 'paintings.moderation_options.auto',
|
auto: "paintings.moderation_options.auto",
|
||||||
low: 'paintings.moderation_options.low'
|
low: "paintings.moderation_options.low",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getPaintingsModerationOptionsLabel = (key: string): string => {
|
export const getPaintingsModerationOptionsLabel = (key: string): string => {
|
||||||
return getLabel(paintingsModerationOptionsKeyMap, key)
|
return getLabel(paintingsModerationOptionsKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const paintingsBackgroundOptionsKeyMap = {
|
const paintingsBackgroundOptionsKeyMap = {
|
||||||
auto: 'paintings.background_options.auto',
|
auto: "paintings.background_options.auto",
|
||||||
opaque: 'paintings.background_options.opaque',
|
opaque: "paintings.background_options.opaque",
|
||||||
transparent: 'paintings.background_options.transparent'
|
transparent: "paintings.background_options.transparent",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getPaintingsBackgroundOptionsLabel = (key: string): string => {
|
export const getPaintingsBackgroundOptionsLabel = (key: string): string => {
|
||||||
return getLabel(paintingsBackgroundOptionsKeyMap, key)
|
return getLabel(paintingsBackgroundOptionsKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const mcpTypeKeyMap = {
|
const mcpTypeKeyMap = {
|
||||||
inMemory: 'settings.mcp.types.inMemory',
|
inMemory: "settings.mcp.types.inMemory",
|
||||||
sse: 'settings.mcp.types.sse',
|
sse: "settings.mcp.types.sse",
|
||||||
stdio: 'settings.mcp.types.stdio',
|
stdio: "settings.mcp.types.stdio",
|
||||||
streamableHttp: 'settings.mcp.types.streamableHttp'
|
streamableHttp: "settings.mcp.types.streamableHttp",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getMcpTypeLabel = (key: string): string => {
|
export const getMcpTypeLabel = (key: string): string => {
|
||||||
return getLabel(mcpTypeKeyMap, key)
|
return getLabel(mcpTypeKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const miniappsStatusKeyMap = {
|
const miniappsStatusKeyMap = {
|
||||||
visible: 'settings.miniapps.visible',
|
visible: "settings.miniapps.visible",
|
||||||
disabled: 'settings.miniapps.disabled'
|
disabled: "settings.miniapps.disabled",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getMiniappsStatusLabel = (key: string): string => {
|
export const getMiniappsStatusLabel = (key: string): string => {
|
||||||
return getLabel(miniappsStatusKeyMap, key)
|
return getLabel(miniappsStatusKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const httpMessageKeyMap = {
|
const httpMessageKeyMap = {
|
||||||
'400': 'error.http.400',
|
"400": "error.http.400",
|
||||||
'401': 'error.http.401',
|
"401": "error.http.401",
|
||||||
'403': 'error.http.403',
|
"403": "error.http.403",
|
||||||
'404': 'error.http.404',
|
"404": "error.http.404",
|
||||||
'429': 'error.http.429',
|
"429": "error.http.429",
|
||||||
'500': 'error.http.500',
|
"500": "error.http.500",
|
||||||
'502': 'error.http.502',
|
"502": "error.http.502",
|
||||||
'503': 'error.http.503',
|
"503": "error.http.503",
|
||||||
'504': 'error.http.504'
|
"504": "error.http.504",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getHttpMessageLabel = (key: string): string => {
|
export const getHttpMessageLabel = (key: string): string => {
|
||||||
return getLabel(httpMessageKeyMap, key)
|
return getLabel(httpMessageKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const reasoningEffortOptionsKeyMap: Record<ThinkingOption, string> = {
|
const reasoningEffortOptionsKeyMap: Record<ThinkingOption, string> = {
|
||||||
off: 'assistants.settings.reasoning_effort.off',
|
off: "assistants.settings.reasoning_effort.off",
|
||||||
minimal: 'assistants.settings.reasoning_effort.minimal',
|
minimal: "assistants.settings.reasoning_effort.minimal",
|
||||||
high: 'assistants.settings.reasoning_effort.high',
|
high: "assistants.settings.reasoning_effort.high",
|
||||||
low: 'assistants.settings.reasoning_effort.low',
|
low: "assistants.settings.reasoning_effort.low",
|
||||||
medium: 'assistants.settings.reasoning_effort.medium',
|
medium: "assistants.settings.reasoning_effort.medium",
|
||||||
auto: 'assistants.settings.reasoning_effort.default'
|
auto: "assistants.settings.reasoning_effort.default",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getReasoningEffortOptionsLabel = (key: string): string => {
|
export const getReasoningEffortOptionsLabel = (key: string): string => {
|
||||||
return getLabel(reasoningEffortOptionsKeyMap, key)
|
return getLabel(reasoningEffortOptionsKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const fileFieldKeyMap = {
|
const fileFieldKeyMap = {
|
||||||
created_at: 'files.created_at',
|
created_at: "files.created_at",
|
||||||
size: 'files.size',
|
size: "files.size",
|
||||||
name: 'files.name'
|
name: "files.name",
|
||||||
} as const
|
} as const;
|
||||||
|
|
||||||
export const getFileFieldLabel = (key: string): string => {
|
export const getFileFieldLabel = (key: string): string => {
|
||||||
return getLabel(fileFieldKeyMap, key)
|
return getLabel(fileFieldKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|
||||||
const builtInMcpDescriptionKeyMap: Record<BuiltinMCPServerName, string> = {
|
const builtInMcpDescriptionKeyMap: Record<BuiltinMCPServerName, string> = {
|
||||||
[BuiltinMCPServerNames.mcpAutoInstall]: 'settings.mcp.builtinServersDescriptions.mcp_auto_install',
|
[BuiltinMCPServerNames.mcpAutoInstall]:
|
||||||
[BuiltinMCPServerNames.memory]: 'settings.mcp.builtinServersDescriptions.memory',
|
"settings.mcp.builtinServersDescriptions.mcp_auto_install",
|
||||||
[BuiltinMCPServerNames.sequentialThinking]: 'settings.mcp.builtinServersDescriptions.sequentialthinking',
|
[BuiltinMCPServerNames.memory]:
|
||||||
[BuiltinMCPServerNames.braveSearch]: 'settings.mcp.builtinServersDescriptions.brave_search',
|
"settings.mcp.builtinServersDescriptions.memory",
|
||||||
[BuiltinMCPServerNames.fetch]: 'settings.mcp.builtinServersDescriptions.fetch',
|
[BuiltinMCPServerNames.sequentialThinking]:
|
||||||
[BuiltinMCPServerNames.filesystem]: 'settings.mcp.builtinServersDescriptions.filesystem',
|
"settings.mcp.builtinServersDescriptions.sequentialthinking",
|
||||||
[BuiltinMCPServerNames.difyKnowledge]: 'settings.mcp.builtinServersDescriptions.dify_knowledge',
|
[BuiltinMCPServerNames.braveSearch]:
|
||||||
[BuiltinMCPServerNames.python]: 'settings.mcp.builtinServersDescriptions.python'
|
"settings.mcp.builtinServersDescriptions.brave_search",
|
||||||
} as const
|
[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 => {
|
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 = {
|
const builtinOcrProviderKeyMap = {
|
||||||
system: 'ocr.builtin.system',
|
system: "ocr.builtin.system",
|
||||||
tesseract: '',
|
tesseract: "",
|
||||||
paddleocr: ''
|
paddleocr: "",
|
||||||
} as const satisfies Record<BuiltinOcrProviderId, string>
|
} as const satisfies Record<BuiltinOcrProviderId, string>;
|
||||||
|
|
||||||
export const getBuiltinOcrProviderLabel = (key: BuiltinOcrProviderId) => {
|
export const getBuiltinOcrProviderLabel = (key: BuiltinOcrProviderId) => {
|
||||||
if (key === 'tesseract') return 'Tesseract'
|
if (key === "tesseract") return "Tesseract";
|
||||||
else if (key == 'paddleocr') return 'PaddleOCR'
|
else if (key == "paddleocr") return "PaddleOCR";
|
||||||
else return getLabel(builtinOcrProviderKeyMap, key)
|
else return getLabel(builtinOcrProviderKeyMap, key);
|
||||||
}
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user