Hi, I’m using pragmaflows JS component to get the users device language, but it’s not detecting it. the code should be correct as it’s made by a programmer instead of AI, but it still does not detect it. Anyone with a similar problem?
I removed the code comments when putting it in
var navigatorLocale = navigator.language || navigator.userLanguage;
var supportedLanguages = [
'en', // English
'es', // Spanish
'pt', // Portuguese
'de', // German
'it', // Italian
'ar', // Arabic
'ru', // Russian
'fr' // French
];
var defaultLanguage = 'en'; // English is the default language
let userLocale = navigatorLocale?.split('-')[0].toLowerCase() ?? defaultLanguage
if (supportedLanguages.indexOf(userLocale.toLowerCase()) === -1) {
userLocale = defaultLanguage;
}
return userLocale;
No problems in here and I get the correct code for my device language. Are you testing this on a mobile or a desktop? Did you changed your browser language while opening the app? If it is reload your app after changing the language and check again!