element-plus/docs/.vitepress/lang.js
jeremywu 7fa9afaa43
feat(docs): document website enhancement (#3580)
- Add language jump support
- Fix ifBuild.sh bug on posix platform
2021-09-23 11:08:19 +08:00

16 lines
403 B
JavaScript

;(() => {
const supportedLangs = window.supportedLangs
const userPreferredLang =
localStorage.getItem('preferred_lang') || navigator.language
if (
supportedLangs.includes(userPreferredLang) &&
!location.pathname.startsWith(`/${userPreferredLang}`)
) {
location.pathname = [`/${userPreferredLang}`]
.concat(location.pathname.split('/').slice(2))
.join('/')
}
})()