From b14a87c3bc1d0022d79731261d83b07a154084c3 Mon Sep 17 00:00:00 2001
From: Elias Nahum <nahumhbl@gmail.com>
Date: Thu, 24 Mar 2016 15:25:03 -0300
Subject: PLT-2358: Detect user localization using client headers

---
 webapp/action_creators/global_actions.jsx | 8 ++++++++
 1 file changed, 8 insertions(+)

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

diff --git a/webapp/action_creators/global_actions.jsx b/webapp/action_creators/global_actions.jsx
index ab38532a6..196d2b32c 100644
--- a/webapp/action_creators/global_actions.jsx
+++ b/webapp/action_creators/global_actions.jsx
@@ -264,6 +264,14 @@ export function newLocalizationSelected(locale) {
     }
 }
 
+export function loadBrowserLocale() {
+    let locale = (navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage)).split('-')[0];
+    if (!I18n.getLanguages()[locale]) {
+        locale = 'en';
+    }
+    return newLocalizationSelected(locale);
+}
+
 export function viewLoggedIn() {
     AsyncClient.getChannels();
     AsyncClient.getChannelExtraInfo();
-- 
cgit v1.2.3-1-g7c22

