From d1354ec48986db5730f8d9493e09df560b136338 Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Tue, 19 May 2020 18:18:16 +0200 Subject: [PATCH] Minor tweak --- src/utils/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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