diff --git a/src/store/index.js b/src/store/index.js index 53da26c..dfe9b2a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -27,9 +27,12 @@ const store = new Vuex.Store(options); if ([undefined, null].includes(store.state.settings.lang)) { const defaultLang = "en"; - // when more languages are available, use Map instead of prefer logic - const preferChinese = navigator.language.slice(0, 2) === "zh"; - store.state.settings.lang = preferChinese ? "zh-CN" : defaultLang; + const langMapper = new Map() + .set("zh", "zh-CN") + .set("en", "en") + .set("tr", "tr"); + store.state.settings.lang = + langMapper.get(navigator.language.slice(0, 2)) || defaultLang; localStorage.setItem("settings", JSON.stringify(store.state.settings)); }