Created
February 21, 2018 15:34
-
-
Save cedeber/ab2f75c03f75a6dc0d71f4a4e5af5d98 to your computer and use it in GitHub Desktop.
Set locale from browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const def = ["en", "fr", "de"]; | |
let locale = navigator.language.indexOf("-") === -1 | |
? navigator.language | |
: navigator.language.split("-")[0]; | |
locale = def.indexOf(locale) === -1 ? def[0] : locale; | |
document.documentElement.lang = locale; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment