MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / initLanguage

Function initLanguage

src/locales/locales.ts:39–61  ·  view source on GitHub ↗
(lng: string = "en-US")

Source from the content-addressed store, hash-verified

37});
38
39export function initLanguage(lng: string = "en-US"): void {
40 i18n.use(initReactI18next).init({
41 fallbackLng: "en-US",
42 lng: lng, // 优先使用localStorage中的语言设置
43 interpolation: {
44 escapeValue: false, // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
45 },
46 resources: {
47 "en-US": { title: "English", translation: enUS },
48 "zh-CN": { title: "简体中文", translation: zhCN },
49 "zh-TW": { title: "繁体中文", translation: zhTW },
50 "ja-JP": { title: "日本語", translation: jaJP },
51 "de-DE": { title: "Deutsch", translation: deDE },
52 "vi-VN": { title: "Tiếng Việt", translation: viVN },
53 "ru-RU": { title: "Русский", translation: ruRU },
54 },
55 });
56
57 // 先根据默认语言设置路径
58 if (!lng.startsWith("zh-")) {
59 localePath = "/en";
60 }
61}
62
63export function initLocales(systemConfig: SystemConfig) {
64 const uiLanguage = chrome.i18n.getUILanguage();

Callers 2

initMethod · 0.90
initLocalesFunction · 0.85

Calls 2

initMethod · 0.65
useMethod · 0.65

Tested by

no test coverage detected