mirror of
https://github.com/go-gost/gost-ui.git
synced 2024-08-11 17:53:29 +00:00
fix: build error
This commit is contained in:
+9
-7
@@ -1,10 +1,12 @@
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
import { isValidElement } from "react"
|
||||
const en = await import("../i18n/en.json");
|
||||
const zh = await import("../i18n/zh.json");
|
||||
const fallbackLng = 'en';
|
||||
import { isValidElement } from "react";
|
||||
import en from '../i18n/en.json';
|
||||
import zh from '../i18n/en.json';
|
||||
// const en = await import("../i18n/en.json");
|
||||
// const zh = await import("../i18n/zh.json");
|
||||
const fallbackLng = "en";
|
||||
i18n
|
||||
// 检测用户当前使用的语言
|
||||
// 文档: https://github.com/i18next/i18next-browser-languageDetector
|
||||
@@ -26,9 +28,9 @@ i18n
|
||||
});
|
||||
|
||||
export function getLabel(label: string | { [key: string]: string }) {
|
||||
if(typeof label === "string") return label;
|
||||
if(isValidElement(label)) return label;
|
||||
if (typeof label === "string") return label;
|
||||
if (isValidElement(label)) return label;
|
||||
const lang = i18n.resolvedLanguage!;
|
||||
return label[lang] || label[fallbackLng] || '<unknown>';
|
||||
return label[lang] || label[fallbackLng] || "<unknown>";
|
||||
}
|
||||
export default i18n;
|
||||
|
||||
Reference in New Issue
Block a user