Bug 1460654 - Trigger eager l10n for listbox items in Preferences::Languages subdialog to avoid overflow. r?jaws
MozReview-Commit-ID: 6MR2YFbubYX
--- a/browser/components/preferences/languages.js
+++ b/browser/components/preferences/languages.js
@@ -127,17 +127,17 @@ var gLanguagesDialog = {
// Re-append items in the correct order:
items.forEach(item => frag.appendChild(item));
availableLanguagesPopup.appendChild(frag);
this._availableLanguages.setAttribute("label", this._availableLanguages.getAttribute("placeholder"));
},
- readAcceptLanguages() {
+ async readAcceptLanguages() {
while (this._activeLanguages.hasChildNodes())
this._activeLanguages.firstChild.remove();
var selectedIndex = 0;
var preference = Preferences.get("intl.accept_languages");
if (preference.value == "")
return undefined;
var languages = preference.value.toLowerCase().split(/\s*,\s*/);
@@ -153,16 +153,21 @@ var gLanguagesDialog = {
code: languages[i],
});
// Hash this language as an "Active" language so we don't
// show it in the list that can be added.
this._acceptLanguages[languages[i]] = true;
}
+ // We're forcing an early localization here because otherwise
+ // the initial sizing of the dialog will happen before it and
+ // result in overflow.
+ await document.l10n.translateFragment(this._activeLanguages);
+
if (this._activeLanguages.childNodes.length > 0) {
this._activeLanguages.ensureIndexIsVisible(selectedIndex);
this._activeLanguages.selectedIndex = selectedIndex;
}
// Update states of accept-language list and buttons according to
// privacy.resistFingerprinting and privacy.spoof_english.
this.readSpoofEnglish();