(lng: string = "en-US")
| 37 | }); |
| 38 | |
| 39 | export 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 | |
| 63 | export function initLocales(systemConfig: SystemConfig) { |
| 64 | const uiLanguage = chrome.i18n.getUILanguage(); |
no test coverage detected