Last active
July 10, 2021 13:37
-
-
Save ksol/62b489572944ca70b4ba to your computer and use it in GitHub Desktop.
Language detection in javascript
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
window.navigator.language // -> "fr" | |
window.navigator.languages // -> ["fr-FR", "fr", "en-US", "en", "es", "de"] | |
window.navigator.userLanguage // -> undefined | |
window.navigator.browserLanguage // -> undefined | |
window.navigator.systemLanguage // -> undefined |
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
window.navigator.language // -> "fr" | |
window.navigator.languages // -> [ "fr", "fr-FR", "en-US", "en" ] | |
window.navigator.userLanguage // -> undefined | |
window.navigator.browserLanguage // -> undefined | |
window.navigator.systemLanguage // -> undefined |
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
window.navigator.language // -> undefined | |
window.navigator.languages // -> undefined | |
window.navigator.userLanguage // -> 'en-us' | |
window.navigator.browserLanguage // -> 'en-us' | |
window.navigator.systemLanguage // -> 'en-us' |
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
window.navigator.language // -> undefined | |
window.navigator.languages // -> undefined | |
window.navigator.userLanguage // -> 'en-US' | |
window.navigator.browserLanguage // -> 'en-US' | |
window.navigator.systemLanguage // -> 'en-US' |
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
window.navigator.language // -> 'en-US' | |
window.navigator.languages // -> undefined | |
window.navigator.userLanguage // -> 'en-US' | |
window.navigator.browserLanguage // -> 'en-US' | |
window.navigator.systemLanguage // -> 'en-US' |
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
window.navigator.language // -> "fr-fr" | |
window.navigator.languages // -> undefined | |
window.navigator.userLanguage // -> undefined | |
window.navigator.browserLanguage // -> undefined | |
window.navigator.systemLanguage // -> undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error TS2339: Property 'systemLanguage' does not exist on type 'Navigator'
To avoid errors this Typescript error you have to change the last 3 lines of code: