diff --git a/src/utils/index.js b/src/utils/index.js index 309c1dc..ad652a8 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -78,12 +78,14 @@ export const addPolyfills = () => { * Helper to init the i18n class with a pre-defined or auto-detected locale. */ export const setLocale = locale => { - try { - const l = locale === 'auto' ? - window.navigator.userLanguage || window.navigator.language : locale; + if (locale) { + try { + const l = locale === 'auto' ? + window.navigator.userLanguage || window.navigator.language : locale; - I18n.init(l); - } catch (error) { - console.warn(`Unsupported locale '${locale}'. Falling back to default en.`); + I18n.init(l); + } catch (error) { + console.warn(`Unsupported locale '${locale}'. Falling back to default en.`); + } } } \ No newline at end of file