MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / initI18n

Function initI18n

frontend/src/lang/i18n.ts:86–114  ·  view source on GitHub ↗
(lang: string)

Source from the content-addressed store, hash-verified

84 return langModule?.default ?? langModule;
85};
86async function initI18n(lang: string) {
87 const { state } = useAppStateStore();
88 lang = toStandardLang(lang);
89
90 const langFiles = import.meta.glob("../../../languages/*.json");
91 for (const path in langFiles) {
92 const langFile = langFiles[path];
93 if (typeof langFile !== "function") continue;
94
95 if (state.isInstall) {
96 if (!toStandardLang(path).includes(lang)) continue;
97 messages[lang] = normalizeLangModule(await langFiles[path]());
98 break;
99 }
100
101 for (const l of SUPPORTED_LANGS) {
102 if (!toStandardLang(path).includes(l.value)) continue;
103 messages[l.value] = normalizeLangModule(await langFiles[path]());
104 }
105 }
106
107 i18n = createI18n({
108 allowComposition: true,
109 globalInjection: true,
110 locale: lang,
111 fallbackLocale: toStandardLang("en_us"),
112 messages: messages
113 });
114}
115
116export function getI18nInstance() {
117 return i18n;

Callers 1

initAppFunction · 0.90

Calls 2

toStandardLangFunction · 0.85
normalizeLangModuleFunction · 0.85

Tested by

no test coverage detected