From 90eafb557c57c3937fcf4733f533a656c19396ec Mon Sep 17 00:00:00 2001 From: Helmut Januschka Date: Tue, 21 Aug 2018 19:52:02 +0200 Subject: [PATCH] fix language detection in IE11 and Edge (#1810) --- client/coral-framework/services/i18n.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/coral-framework/services/i18n.js b/client/coral-framework/services/i18n.js index 42a0b2030..f7553c05a 100644 --- a/client/coral-framework/services/i18n.js +++ b/client/coral-framework/services/i18n.js @@ -75,10 +75,15 @@ let TIMEAGO_INSTANCE; // detectLanguage will try to get the locale from storage if available, // otherwise will try to get it from the navigator, otherwise, it will fallback // to the default language. -const detectLanguage = () => - first( +const detectLanguage = () => { + var browserLanguages = navigator.languages; + //IE11 and MS-EDGE do not provide navigator.languages + if (!browserLanguages) { + browserLanguages = [navigator.language]; + } + return first( negotiateLanguages( - navigator.languages, + browserLanguages, whitelistedLanguages || supportedLocales, { defaultLocale, @@ -86,6 +91,7 @@ const detectLanguage = () => } ) ); +}; export function setupTranslations() { // locale