Skip to content

Commit

Permalink
Merge pull request #14 from ChanTsune/fix/object-hasOwn
Browse files Browse the repository at this point in the history
fix Object.hasOwn does not exist
  • Loading branch information
ChanTsune authored Jan 17, 2023
2 parents f8b65a9 + 6e3a89e commit 355d048
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@ import { Descritption, initDescription } from "./description";
import { en } from "./locales/en";
import { ja } from "./locales/ja";

const Languages = [
"en",
"ja",
]

const Descriptions = {
en,
ja,
}
const Languages = new Map([
["en", en],
["ja", ja],
]);

export function getLangDescription(language: string): Descritption {
let desc:Descritption=initDescription();

Languages.map((lang) => {
desc = Object.hasOwn(Descriptions, lang)
? Descriptions[language as keyof typeof Descriptions]
: Descriptions.en;//console.log(`${lang} is not supported`);
})
return desc;
return Languages.get(language) || initDescription();
}

0 comments on commit 355d048

Please sign in to comment.