Bug 1046142 - Empty language to translate to drop down on localized builds, r=gavin.

--HG--
extra : rebase_source : 0d2c4d772a672a4b2f7db28ea5cf0905d58b03b1
This commit is contained in:
Florian Quèze 2014-08-01 15:18:46 +02:00
parent ceb2d8521a
commit 5d90edf24b
2 changed files with 13 additions and 6 deletions

View File

@ -32,8 +32,8 @@ this.Translation = {
serviceUnavailable: false,
supportedSourceLanguages: ["zh", "de", "en", "fr", "ja", "ko", "pt", "ru", "es"],
supportedTargetLanguages: ["zh", "de", "en", "fr", "ja", "ko", "pt", "ru", "es"],
supportedSourceLanguages: ["de", "en", "es", "fr", "ja", "ko", "pt", "ru", "zh"],
supportedTargetLanguages: ["de", "en", "es", "fr", "ja", "ko", "pl", "pt", "ru", "tr", "vi", "zh"],
_defaultTargetLanguage: "",
get defaultTargetLanguage() {

View File

@ -166,12 +166,17 @@
let bundle = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://global/locale/languageNames.properties");
let sortByLocalizedName = function(aList) {
return aList.map(code => [code, bundle.GetStringFromName(code)])
.sort((a, b) => a[1].localeCompare(b[1]));
};
// Fill the lists of supported source languages.
let detectedLanguage = this._getAnonElt("detectedLanguage");
let fromLanguage = this._getAnonElt("fromLanguage");
for (let code of Translation.supportedSourceLanguages) {
let name = bundle.GetStringFromName(code);
let sourceLanguages =
sortByLocalizedName(Translation.supportedSourceLanguages);
for (let [code, name] of sourceLanguages) {
detectedLanguage.appendItem(name, code);
fromLanguage.appendItem(name, code);
}
@ -183,8 +188,10 @@
// Fill the list of supported target languages.
let toLanguage = this._getAnonElt("toLanguage");
for (let code of Translation.supportedTargetLanguages)
toLanguage.appendItem(bundle.GetStringFromName(code), code);
let targetLanguages =
sortByLocalizedName(Translation.supportedTargetLanguages);
for (let [code, name] of targetLanguages)
toLanguage.appendItem(name, code);
if (aTranslation.translatedTo)
toLanguage.value = aTranslation.translatedTo;