Save last forced language
This commit is contained in:
parent
83bc51c8af
commit
9119b24095
1 changed files with 5 additions and 0 deletions
|
@ -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('-', '_')
|
||||
|
|
Loading…
Reference in a new issue