From 6fa76bf8e3b4af2ff8933e21f92fb6c933131458 Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Mon, 10 Oct 2022 12:33:11 +0200 Subject: [PATCH] mainlanguage - if not single, try selecting based on browser --- src/lib/i18n.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/i18n.js b/src/lib/i18n.js index 9cd02d25b..90a73331a 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -41,7 +41,14 @@ const languages = { const mainLanguage = (countryCode, single = true) => { // single: remove countries with multiple languages const l = languages[countryCode.toLowerCase()]; - if (single && Array.isArray(l)) return null; + if (single && Array.isArray(l)) { + const browserLang = navigator.language.split('-')[0]; + if (l.indexOf(browserLang) >= 0) { + return browserLang; + } else { + return null; + } + }; return l; };