Set default locale to "en" when fail to detect user locale
first, trying to detect locale from local storage
second, trying to detect locale from cookie
default, set locale to "en"
@@ -4,9 +4,9 @@ class Utils {
}
isLocale(locale) {
- return document.cookie.split(';')
- .find(c => c.indexOf('naveruserlocale=') > -1)
- .split('=')[1] === locale;
+ const localStorageLocale = localStorage.getItem('naveruserlocale');
+ const cookieLocale = document.cookie.split(';').find(c => c.indexOf('naveruserlocale=') > -1);
+ return locale === (localStorageLocale || cookieLocale || "en");
}
isNumeric(num){
