Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Sort languages via their display names #7593

Merged
merged 3 commits into from
Apr 23, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/extensions/default/DebugCommands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ define(function (require, exports, module) {

return i18n === undefined ? locale : i18n;
};

// add system default
languages.push({label: Strings.LANGUAGE_SYSTEM_DEFAULT, language: null});

// add english
languages.push({label: getLocalizedLabel("en"), language: "en"});

// inspect all children of dirEntry
entries.forEach(function (entry) {
Expand All @@ -191,6 +185,16 @@ define(function (require, exports, module) {
}
}
});
// sort the languages via their display name
languages.sort(function (lang1, lang2) {
var langName1 = lang1.label,
langName2 = lang2.label;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really no need to create these vars since they are only used once. Could simply be:

                languages.sort(function (lang1, lang2) {
                    return lang1.label.localeCompare(lang2.label);
                });


return langName1.localeCompare(langName2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SAplayer I noticed that there are three languages (Ελληνικά, русский and српски) that seem to be in the wrong places. Maybe the first letter in those languages are not the regular ascii latin1 characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought about in #7516, and @njx said we should do it either way.
Btw, I just looked up the Google language switching page. Click Show more and you'll see the same order (issues).

E: I just saw the chars you wrote are looking like latin chars, but they are not. It's Ε U+0395, р U+0440 and с U+0441.

});

// add system default and english (those should be on the very top)
languages.unshift({label: Strings.LANGUAGE_SYSTEM_DEFAULT, language: null}, {label: getLocalizedLabel("en"), language: "en"});

var template = Mustache.render(LanguageDialogTemplate, {languages: languages, Strings: Strings});
Dialogs.showModalDialogUsingTemplate(template).done(function (id) {
Expand Down