Commit 41edd056 authored by JC Brand's avatar JC Brand

Don't try to parse non-strings

parent c7d66377
......@@ -457,14 +457,16 @@
}
utils.getLocale = function (preferred_locale, isSupportedByLibrary) {
if (preferred_locale === 'en' || isSupportedByLibrary(preferred_locale)) {
return preferred_locale;
}
try {
var obj = window.JSON.parse(preferred_locale);
return obj.locale_data.converse[""].lang;
} catch (e) {
console.log(e);
if (_.isString(preferred_locale)) {
if (preferred_locale === 'en' || isSupportedByLibrary(preferred_locale)) {
return preferred_locale;
}
try {
var obj = window.JSON.parse(preferred_locale);
return obj.locale_data.converse[""].lang;
} catch (e) {
console.log(e);
}
}
return utils.detectLocale(isSupportedByLibrary) || 'en';
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment