Skip to content

Commit

Permalink
add zh-TW
Browse files Browse the repository at this point in the history
  • Loading branch information
guopenghui committed Nov 30, 2022
1 parent 39df305 commit 77a8eca
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/lang/helper.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import zh from "./locale/zh"
import en from "./locale/en"
import zh from "./locale/zh";
import en from "./locale/en";
import zhTW from "./locale/zh-TW";

const localeMap: { [k: string]: Partial<typeof en> } = {
const localeMap: { [k: string]: Partial<typeof en>; } = {
en,
zh,
}
"zh-TW": zhTW,
};


const lang = window.localStorage.getItem("language")
const locale = localeMap[lang || "en"]
const lang = window.localStorage.getItem("language");
const locale = localeMap[lang || "en"];

export function t(text: keyof typeof en): string {
return (locale && locale[text]) || en[text]
return (locale && locale[text]) || en[text];
}

0 comments on commit 77a8eca

Please sign in to comment.