From 159953050a9c4fb700bbde79042ead4843b0bea5 Mon Sep 17 00:00:00 2001
From: enahum <nahumhbl@gmail.com>
Date: Thu, 2 Jun 2016 16:47:26 -0300
Subject: PLT-1800 Load server side locale from the config.json (#3202)

* PLT-1800 Load server side locale from the config.json

* Add support for locales with country specifics

* Fix localization on served locale file as plain/text

* Remove github.com/cloudfoundry/jibber_jabber as vendor dependency

* Fix get locale on login_controller
---
 webapp/actions/global_actions.jsx | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

(limited to 'webapp/actions/global_actions.jsx')

diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index 91b51a9c2..0b264a9b3 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -392,8 +392,10 @@ export function newLocalizationSelected(locale) {
             translations: en
         });
     } else {
+        const localeInfo = I18n.getLanguageInfo(locale) || I18n.getLanguageInfo(global.window.mm_config.DefaultClientLocale);
+
         Client.getTranslations(
-            I18n.getLanguageInfo(locale).url,
+            localeInfo.url,
             (data, res) => {
                 let translations = data;
                 if (!data && res.text) {
@@ -412,16 +414,11 @@ export function newLocalizationSelected(locale) {
     }
 }
 
-export function loadBrowserLocale() {
-    let locale = (navigator.languages && navigator.languages.length > 0 ? navigator.languages[0] :
-        (navigator.language || navigator.userLanguage)).split('-')[0];
-
-    const user = UserStore.getCurrentUser();
-    if (user) {
-        locale = user.locale || locale;
-    }
+export function loadDefaultLocale() {
+    const defaultLocale = global.window.mm_config.DefaultClientLocale;
+    let locale = global.window.mm_user ? global.window.mm_user.locale || defaultLocale : defaultLocale;
 
-    if (!I18n.getLanguages()[locale]) {
+    if (!I18n.getLanguageInfo(locale)) {
         locale = 'en';
     }
     return newLocalizationSelected(locale);
-- 
cgit v1.2.3-1-g7c22

