From d4e64bcc014686212f27ff9538f957a5356bd5d0 Mon Sep 17 00:00:00 2001 From: Axolotle Date: Mon, 6 Jul 2020 22:47:51 +0200 Subject: [PATCH] add temp browser locale getter --- app/src/plugins/i18n.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/plugins/i18n.js b/app/src/plugins/i18n.js index 6699ab12..5c7b9266 100644 --- a/app/src/plugins/i18n.js +++ b/app/src/plugins/i18n.js @@ -16,8 +16,19 @@ function loadLocaleMessages () { return messages } +function getBrowserLocale() { + const navigatorLocale = navigator.languages !== undefined + ? navigator.languages[0] + : navigator.language + + return !navigatorLocale + ? undefined + : navigatorLocale +} + export default new VueI18n({ - locale: process.env.VUE_APP_I18N_LOCALE || 'en', - fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', + locale: getBrowserLocale(), + fallbackLocale: 'en', + // TODO : chunk locales json and lazy load them messages: loadLocaleMessages() })