Files
tashow-h5/projects/translate-h5/src/hooks/i18n.ts
2025-09-05 15:18:10 +08:00

13 lines
344 B
TypeScript

import zhCN from "@/locales/zh_CN.json";
import enUS from "@/locales/en_US.json";
import { useI18nStore } from "@/store/i18n";
export default function useI18n() {
const { lang } = useI18nStore();
const locales = lang === "en_US" ? enUS : zhCN;
return (name: string) => {
return locales[name as keyof typeof locales] || name;
};
}