From 225ea35895bdc641b69551c6b50a827fdd1edc7f Mon Sep 17 00:00:00 2001
From: enahum <nahumhbl@gmail.com>
Date: Fri, 12 Aug 2016 06:51:00 -0500
Subject: PLT-3793 Re-order languages in Account Settings (#3756)

---
 .../components/user_settings/manage_languages.jsx  | 35 +++++++++++++---------
 1 file changed, 21 insertions(+), 14 deletions(-)

(limited to 'webapp/components/user_settings/manage_languages.jsx')

diff --git a/webapp/components/user_settings/manage_languages.jsx b/webapp/components/user_settings/manage_languages.jsx
index ed82bc666..f4ae79088 100644
--- a/webapp/components/user_settings/manage_languages.jsx
+++ b/webapp/components/user_settings/manage_languages.jsx
@@ -64,20 +64,27 @@ export default class ManageLanguage extends React.Component {
         }
 
         const options = [];
-        const languages = I18n.getLanguages();
-        for (const key in languages) {
-            if (languages.hasOwnProperty(key)) {
-                const lang = languages[key];
-                options.push(
-                    <option
-                        key={lang.value}
-                        value={lang.value}
-                    >
-                        {lang.name}
-                    </option>
-                );
-            }
-        }
+        const locales = I18n.getLanguages();
+
+        const languages = Object.keys(locales).map((l) => {
+            return {
+                value: locales[l].value,
+                name: locales[l].name,
+                order: locales[l].order
+            };
+        }).
+        sort((a, b) => a.order - b.order);
+
+        languages.forEach((lang) => {
+            options.push(
+                <option
+                    key={lang.value}
+                    value={lang.value}
+                >
+                    {lang.name}
+                </option>
+            );
+        });
 
         const input = (
             <div key='changeLanguage'>
-- 
cgit v1.2.3-1-g7c22

