NavigationLanguage.language
or the first NavigationLanguage.languages
if available, otherwise return defaultLang
.defaultLang
, to use 'en-US'
as the default language code.const detectLanguage = (defaultLang = 'en-US') =>
navigator.language ||
(Array.isArray(navigator.languages) && navigator.languages[0]) ||
defaultLang;
detectLanguage(); // 'nl-NL'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️