fix: build error

This commit is contained in:
cnwhy
2024-06-13 18:50:25 +08:00
parent 2f843862b4
commit 0a84b8c8d9
+9 -7
View File
@@ -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;