Bug 1435034 - Display of default fonts is broken in preferences after Bug 1344990 and Bug 1378366 (Take II). r=frg
authorrsx11m <rsx11m.pub@gmail.com>
Sun, 11 Feb 2018 13:23:34 -0600
changeset 31088 d116981753de2b088dca15dc4ec3d32de127b43d
parent 31087 c125f006ce8c1b3db75c684246e6f3c8e6de2357
child 31089 8c7e7fdff34e61378d8e8cf1067f92bce66489cb
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersfrg
bugs1435034, 1344990, 1378366
Bug 1435034 - Display of default fonts is broken in preferences after Bug 1344990 and Bug 1378366 (Take II). r=frg
suite/common/pref/pref-fonts.js
suite/locales/en-US/chrome/common/pref/prefutilities.properties
--- a/suite/common/pref/pref-fonts.js
+++ b/suite/common/pref/pref-fonts.js
@@ -38,36 +38,35 @@ function BuildFontList(aLanguage, aFontT
 
   // Reset the list
   while (aMenuList.hasChildNodes())
     aMenuList.lastChild.remove();
 
   // Build the UI for the Default Font and Fonts for this CSS type.
   var popup = document.createElement("menupopup");
   var separator;
-  if (fonts.length)
+  if (fonts.length > 0)
   {
-    if (defaultFont)
-    {
-      var prefutilitiesBundle = document.getElementById("bundle_prefutilities");
-      var label = prefutilitiesBundle.getFormattedString("labelDefaultFont", [defaultFont]);
-      var menuitem = document.createElement("menuitem");
-      menuitem.setAttribute("label", label);
-      menuitem.setAttribute("value", ""); // Default Font has a blank value
-      popup.appendChild(menuitem);
+    const prefutilitiesBundle = document.getElementById("bundle_prefutilities");
+    let label = defaultFont ?
+      prefutilitiesBundle.getFormattedString("labelDefaultFont2", [defaultFont]) :
+      prefutilitiesBundle.getString("labelDefaultFontUnnamed");
+    let menuitem = document.createElement("menuitem");
+    menuitem.setAttribute("label", label);
+    menuitem.setAttribute("value", ""); // Default Font has a blank value
+    popup.appendChild(menuitem);
 
-      separator = document.createElement("menuseparator");
-      popup.appendChild(separator);
-    }
+    separator = document.createElement("menuseparator");
+    popup.appendChild(separator);
 
-    for (var i = 0; i < fonts.length; ++i)
+    for (let font of fonts)
     {
       menuitem = document.createElement("menuitem");
-      menuitem.setAttribute("value", fonts[i]);
-      menuitem.setAttribute("label", fonts[i]);
+      menuitem.setAttribute("value", font);
+      menuitem.setAttribute("label", font);
       popup.appendChild(menuitem);
     }
   }
 
   // Build the UI for the remaining fonts.
   if (gAllFonts.length > fonts.length)
   {
     // Both lists are sorted, and the Fonts-By-Type list is a subset of the
--- a/suite/locales/en-US/chrome/common/pref/prefutilities.properties
+++ b/suite/locales/en-US/chrome/common/pref/prefutilities.properties
@@ -22,17 +22,19 @@ offlineAppUsage=%1$S %2$S
 choosehomepage=Choose Home Page
 downloadfolder=Choose a Download Folder
 desktopFolderName=Desktop
 downloadsFolderName=Downloads
 choosesound=Choose a sound
 
 SoundFiles=Sounds
 
-labelDefaultFont=Default (%font_family%)
+# LOCALIZATION NOTE (labelDefaultFont2): %S = font name
+labelDefaultFont2=Default (%S)
+labelDefaultFontUnnamed=Default
 
 # LOCALIZATION NOTE (appLocale.label): %S = Name of the application locale,
 # e.g. English (United States)
 appLocale.label=Application locale: %S
 appLocale.accesskey=n
 # LOCALIZATION NOTE (rsLocale.label): %S = Name of the locale chosen in regional settings,
 # e.g. German (Germany)
 rsLocale.label=Regional settings locale: %S