Update index.ts

This commit is contained in:
Clarence Dan 2023-04-04 17:27:38 +08:00 committed by GitHub
parent feed9c3471
commit e240b0a376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,10 +3,11 @@ import EN from "./en";
import TW from "./tw"; import TW from "./tw";
import ES from "./es"; import ES from "./es";
import IT from "./it"; import IT from "./it";
import JP from "./jp";
export type { LocaleType } from "./cn"; export type { LocaleType } from "./cn";
export const AllLangs = ["en", "cn", "tw", "es", "it"] as const; export const AllLangs = ["en", "cn", "tw", "es", "it", "jp"] as const;
type Lang = (typeof AllLangs)[number]; type Lang = (typeof AllLangs)[number];
const LANG_KEY = "lang"; const LANG_KEY = "lang";
@ -50,6 +51,8 @@ export function getLang(): Lang {
return "es"; return "es";
} else if (lang.includes("it")) { } else if (lang.includes("it")) {
return "it"; return "it";
} else if (lang.includes("jp")) {
return "jp";
} else { } else {
return "en"; return "en";
} }
@ -60,4 +63,4 @@ export function changeLang(lang: Lang) {
location.reload(); location.reload();
} }
export default { en: EN, cn: CN, tw: TW, es: ES, it: IT }[getLang()]; export default { en: EN, cn: CN, tw: TW, es: ES, jp: JP, it: IT }[getLang()];