From 53a7c7bd49d50972f0458dea5af1ac66c477e08c Mon Sep 17 00:00:00 2001 From: Jaya chithra Date: Wed, 22 Mar 2017 05:15:32 +0000 Subject: [PATCH] gui: Sort languages alphabetically (fixes #3813) This change sorts the language selection menu in Syncthing's home page so that the languages are displayed alphabetically. The issue was discussed in #3813. There were few ways of doing this. Sorting the language names in transifix file did not work due to access control. So I sorted the languages directly in languageSelectdirective.js by inverting and sorting the language info retrieved from localeService.js. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4052 --- .../syncthing/core/languageSelectDirective.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gui/default/syncthing/core/languageSelectDirective.js b/gui/default/syncthing/core/languageSelectDirective.js index a6b8e3a35..30fee3ba9 100644 --- a/gui/default/syncthing/core/languageSelectDirective.js +++ b/gui/default/syncthing/core/languageSelectDirective.js @@ -6,8 +6,8 @@ angular.module('syncthing.core') template: ''+ '', @@ -26,8 +26,21 @@ angular.module('syncthing.core') availableLocaleNames[a] = '[' + a + ']'; } } - $scope.localesNames = availableLocaleNames; + + var invert = function (obj) { + var new_obj = {}; + + for (var prop in obj) { + if(obj.hasOwnProperty(prop)) { + new_obj[obj[prop]] = prop; + } + } + return new_obj; + }; + $scope.localesNamesInv = invert($scope.localesNames); + $scope.localesNamesInvKeys = Object.keys($scope.localesNamesInv).sort(); + $scope.visible = $scope.localesNames && $scope.localesNames['en']; // using $watch cause LocaleService.currentLocale will be change after receive async query accepted-languages