From f3260ed8bf4ed29653f27ba61d77de8cc00dea21 Mon Sep 17 00:00:00 2001 From: Ramon Souza Date: Thu, 20 May 2021 14:01:58 -0300 Subject: [PATCH] handle additional cases for locales --- .../imports/startup/server/index.js | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/bigbluebutton-html5/imports/startup/server/index.js b/bigbluebutton-html5/imports/startup/server/index.js index 5f6508e6a3..6ef30c44ea 100755 --- a/bigbluebutton-html5/imports/startup/server/index.js +++ b/bigbluebutton-html5/imports/startup/server/index.js @@ -209,17 +209,31 @@ WebApp.connectHandlers.use('/locale', (req, res) => { let normalizedLocale; + const regionDefault = usableLocales.find(locale => browserLocale[0] === locale); + if (browserLocale.length > 1) { + // browser asks for specific locale normalizedLocale = `${browserLocale[0]}_${browserLocale[1].toUpperCase()}`; const normDefault = usableLocales.find(locale => normalizedLocale === locale); - if (normDefault) localeFile = normDefault; - } - - const regionDefault = usableLocales.find(locale => browserLocale[0] === locale); - - if (localeFile === fallback && regionDefault !== localeFile) { - localeFile = regionDefault; + if (normDefault) { + localeFile = normDefault; + }else{ + if (regionDefault) { + localeFile = regionDefault; + } else { + const specFallback = usableLocales.find(locale => browserLocale[0] === locale.split("_")[0]); + if (specFallback) localeFile = specFallback; + } + } + } else { + // browser asks for region default locale + if (regionDefault && localeFile === fallback && regionDefault !== localeFile) { + localeFile = regionDefault; + } else { + const normFallback = usableLocales.find(locale => browserLocale[0] === locale.split("_")[0]); + if (normFallback) localeFile = normFallback; + } } res.setHeader('Content-Type', 'application/json');