Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
cnwhy committed Jun 13, 2024
1 parent 2f84386 commit 0a84b8c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/uitls/i18n.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

0 comments on commit 0a84b8c

Please sign in to comment.