aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/i18n.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/i18n.js b/src/lib/i18n.js
index 0600a2a8..4cbb9a5d 100644
--- a/src/lib/i18n.js
+++ b/src/lib/i18n.js
@@ -6,6 +6,9 @@ const localeCodes = ['en', 'fr'];
// The directory where locale files are stored
const localeDirectory = "../locales";
+// the default locale to use if none was found
+const defaultLocale = "en";
+
// Adds a new locale based on its code
function addLocale(localeCode) {
register(localeCode, () => import(`${localeDirectory}/${localeCode}.json`));
@@ -13,6 +16,11 @@ function addLocale(localeCode) {
// Picks the default locale based on navigator locale and the list of available locales
function pickLocale(navigatorLocale, availableLocales) {
+ // locale can be null the first time you load this
+ // return the default locale in that case - reloading should fix this
+ if (!navigatorLocale)
+ return defaultLocale;
+
// determine langugage part of locale
// (e.g. if navigatorLocale is 'en-US', languageCode is 'en')
let dashIndex = navigatorLocale ? navigatorLocale.indexOf("-") : -1;
@@ -38,6 +46,6 @@ localeCodes.forEach(addLocale);
let initialLocale = pickLocale(getLocaleFromNavigator(), localeCodes);
init({
- fallbackLocale: 'en',
+ fallbackLocale: defaultLocale,
initialLocale: initialLocale,
});
'#n93'>93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148