Save last forced language

This commit is contained in:
Chocobozzz 2019-10-24 13:15:25 +02:00
parent 83bc51c8af
commit 9119b24095
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -43,8 +43,13 @@ const localePath = window.location.pathname
.replace(/^\//, '')
.replace(/\/$/, '')
const languageFromLocalStorage = localStorage.getItem('language')
if (allLocales.includes(localePath)) {
Vue.config.language = aliasesLanguages[localePath] ? aliasesLanguages[localePath] : localePath
localStorage.setItem('language', Vue.config.language)
} else if (languageFromLocalStorage) {
Vue.config.language = languageFromLocalStorage
} else {
const navigatorLanguage = window.navigator.userLanguage || window.navigator.language
const snakeCaseLanguage = navigatorLanguage.replace('-', '_')