Skip to content

Commit

Permalink
fix: 🐛 Removed dynamic require (kolplattformen#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanObrink authored Apr 27, 2021
1 parent e944468 commit a3421b8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@ interface RawTranslation extends Translation {
specialLanguages: Repo
}

const languageList = ['sv', 'en']
const translations: Translations = {
sv: require('./sv.json'),
en: require('./en.json'),
}
const languageList: string[] = Object.keys(translations)
export type Language = typeof languageList[number]
type Translations = Record<Language, RawTranslation>

const translations: Translations = languageList.reduce(
(map, lang) => ({
...map,
[lang]: require(`./${lang}.json`),
}),
{}
)

const translate = (lang: Language): Translation => {
const selectedLanguage = languageList.includes(lang) ? lang : languageList[0]
const {
Expand Down

0 comments on commit a3421b8

Please sign in to comment.