mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-07 01:02:55 +08:00
2da73a6555
* perf: faq * index * delete dataset * delete dataset * perf: delete dataset * init * fix: faq * refresh * empty tip * perf: delete type * fix: some bugs (#6071) * fix: publish channel doc link * fix: checkbox disable hover style * fix: huggingface.svg missing; update doc * chore: update doc * fix: typo * fix: export log dateend;feat: file selector render (#6072) * fix: export log dateend * feat: file selector render * perf: s3 controller * team qpm limit & plan tracks (#6066) * team qpm limit & plan tracks * api entry qpm * perf: computed days * Revert "api entry qpm" This reverts commit 1210c07217ab4509d54b3eb57067dd94ff8b0da6. * perf: code * system qpm limit * system qpm limit --------- Co-authored-by: archer <545436317@qq.com> * perf: track * remove export chat test * doc * feat: global agent (#6057) * feat: global agent * fix: agent * fix: order display * CHORE * feat: error page log * fix: var update --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: Roy <whoeverimf5@gmail.com>
26 lines
727 B
TypeScript
26 lines
727 B
TypeScript
import type { I18nStringType, localeType } from './type';
|
|
|
|
export const parseI18nString = (str: I18nStringType | string = '', lang = 'en') => {
|
|
if (!str || typeof str === 'string') return str;
|
|
|
|
// 尝试使用当前语言
|
|
if (str[lang as localeType]) {
|
|
return str[lang as localeType] || '';
|
|
}
|
|
|
|
// 如果当前语言是繁体中文但没有对应翻译,优先回退到简体中文
|
|
if (lang === 'zh-Hant' && !str['zh-Hant'] && str['zh-CN']) {
|
|
return str['zh-CN'];
|
|
}
|
|
|
|
// 最后回退到英文
|
|
return str['en'] || '';
|
|
};
|
|
|
|
export const formatI18nLocationToZhEn = (locale: localeType = 'zh-CN'): 'zh' | 'en' => {
|
|
if (locale.toLocaleLowerCase().startsWith('zh')) {
|
|
return 'zh';
|
|
}
|
|
return 'en';
|
|
};
|