Bug 1497694 - Migrate Update History in Update section of Preferences to use Fluent for localization r=Gijs,flod,zbraniecki,jaws
☠☠ backed out by da119c04dff6 ☠ ☠
authorQinghao_Jack_Song <songqing@msu.edu>
Wed, 24 Oct 2018 14:31:10 +0000
changeset 491155 e66bbfad641e0ad2c666a54d315fe37491e923a1
parent 491154 0ffffb5e0954d2e782ea4da7292d617f435ad3c0
child 491156 a90b3d91f1a442866f0cae3a350701f48056c895
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersGijs, flod, zbraniecki, jaws
bugs1497694
milestone65.0a1
Bug 1497694 - Migrate Update History in Update section of Preferences to use Fluent for localization r=Gijs,flod,zbraniecki,jaws Differential Revision: https://phabricator.services.mozilla.com/D8045
browser/components/preferences/in-content/main.xul
browser/components/preferences/in-content/preferences.xul
python/l10n/fluent_migrations/bug_1497687_updateHistory_preferences.py
toolkit/locales/en-US/chrome/mozapps/update/history.dtd
toolkit/locales/en-US/chrome/mozapps/update/updates.properties
toolkit/locales/en-US/toolkit/updates/history.ftl
toolkit/locales/jar.mn
toolkit/mozapps/update/content/history.js
toolkit/mozapps/update/content/history.xul
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -454,17 +454,20 @@
 #ifdef MOZ_UPDATER
     <spacer flex="1"/>
     <!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
     <vbox>
       <button id="showUpdateHistory"
               class="accessory-button"
               data-l10n-id="update-history"
               preference="app.update.disable_button.showUpdateHistory"
-              searchkeywords="&history.title; &history2.intro;"/>
+              search-l10n-ids="
+                history-title,
+                history-intro
+              "/>
     </vbox>
 #endif
   </hbox>
 #ifdef MOZ_UPDATER
   <vbox id="updateBox">
     <deck id="updateDeck" orient="vertical">
       <hbox id="checkForUpdates" align="start">
         <spacer flex="1"/>
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -13,24 +13,22 @@
   href="chrome://browser/content/preferences/handlers.css"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/applications.css"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/in-content/search.css"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/in-content/containers.css"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/in-content/privacy.css"?>
 
 <!DOCTYPE page [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
-<!ENTITY % historyDTD SYSTEM "chrome://mozapps/locale/update/history.dtd">
 <!ENTITY % certManagerDTD SYSTEM "chrome://pippki/locale/certManager.dtd">
 <!ENTITY % deviceManangerDTD SYSTEM "chrome://pippki/locale/deviceManager.dtd">
 <!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
 <!ENTITY % aboutDialogDTD SYSTEM "chrome://browser/locale/aboutDialog.dtd" >
 %aboutDialogDTD;
 %brandDTD;
-%historyDTD;
 %certManagerDTD;
 %deviceManangerDTD;
 %sanitizeDTD;
 ]>
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
       xmlns:html="http://www.w3.org/1999/xhtml"
       disablefastfind="true"
@@ -48,16 +46,17 @@
     <link rel="localization" href="browser/preferences/blocklists.ftl"/>
     <link rel="localization" href="browser/preferences/clearSiteData.ftl"/>
     <link rel="localization" href="browser/preferences/colors.ftl"/>
     <link rel="localization" href="browser/preferences/connection.ftl"/>
     <link rel="localization" href="browser/preferences/languages.ftl"/>
     <link rel="localization" href="browser/preferences/permissions.ftl"/>
     <link rel="localization" href="browser/preferences/selectBookmark.ftl"/>
     <link rel="localization" href="browser/preferences/siteDataSettings.ftl"/>
+    <link rel="localization" href="toolkit/updates/history.ftl"/>
   </linkset>
 
   <html:link rel="shortcut icon"
               href="chrome://browser/skin/settings.svg"/>
 
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
   <script type="application/javascript"
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1497687_updateHistory_preferences.py
@@ -0,0 +1,58 @@
+# coding=utf8
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from __future__ import absolute_import
+import fluent.syntax.ast as FTL
+from fluent.migrate.helpers import transforms_from
+from fluent.migrate import COPY
+from fluent.migrate import REPLACE
+from fluent.migrate import REPLACE_IN_TEXT
+from fluent.migrate.helpers import VARIABLE_REFERENCE
+
+def migrate(ctx):
+    """Bug 1497687 - Migrate Update History in Update section of Preferences to use Fluent for localization, part {index}."""
+
+    ctx.add_transforms(
+        "toolkit/toolkit/updates/history.ftl",
+        "toolkit/toolkit/updates/history.ftl",
+        transforms_from(
+"""
+history-title = { COPY("toolkit/chrome/mozapps/update/history.dtd", "history.title") }
+history-intro = { COPY("toolkit/chrome/mozapps/update/history.dtd", "history2.intro") }
+close-button-label =
+    .buttonlabelcancel = { COPY("toolkit/chrome/mozapps/update/history.dtd", "closebutton.label") }
+    .title = { COPY("toolkit/chrome/mozapps/update/history.dtd", "history.title") }
+no-updates-label = { COPY("toolkit/chrome/mozapps/update/history.dtd", "noupdates.label") }
+name-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "name.header") }
+date-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "date.header") }
+type-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "type.header") }
+state-header = { COPY("toolkit/chrome/mozapps/update/history.dtd", "state.header") }
+""")
+)
+
+    ctx.add_transforms(
+    "toolkit/toolkit/updates/history.ftl",
+    "toolkit/toolkit/updates/history.ftl",
+    [
+        FTL.Message(
+            id=FTL.Identifier("update-full-name"),
+            attributes=[
+                FTL.Attribute(
+                    id=FTL.Identifier("name"),
+                    value=REPLACE(
+                        "toolkit/chrome/mozapps/update/updates.properties",
+                        "updateFullName",
+                        {
+                            "%1$S": VARIABLE_REFERENCE("name"),
+                            "%2$S": VARIABLE_REFERENCE("buildID"),
+                        },
+                        normalize_printf=True
+                    )
+                )
+            ]
+        )
+    ]
+)
+
deleted file mode 100644
--- a/toolkit/locales/en-US/chrome/mozapps/update/history.dtd
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-
-<!ENTITY  history.title             "Update History">
-<!ENTITY  history2.intro            "The following updates have been installed">
-<!ENTITY  closebutton.label         "Close">
-
-<!ENTITY  noupdates.label           "No updates installed yet">
-
-<!ENTITY  name.header               "Update Name">
-<!ENTITY  date.header               "Install Date">
-<!ENTITY  type.header               "Type">
-<!ENTITY  state.header              "State">
-
--- a/toolkit/locales/en-US/chrome/mozapps/update/updates.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/update/updates.properties
@@ -1,17 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-# LOCALIZATION NOTE: The 1st %S is the update name and the 2nd %S is the build
-# identifier from the local updates.xml for displaying update history
-# example: MyApplication (20081022033543)
-updateFullName=%S (%S)
-
 # LOCALIZATION NOTE: The 1st %S is brandShortName and 2nd %S is update version
 # where update version from the update xml
 # example: MyApplication 10.0.5
 updateName=%S %S
 
 # LOCALIZATION NOTE: When present
 # %1$S is the brandShortName. Ex: MyApplication
 # %2$S is the update version - provided by the update xml. Ex: version 10.0.5
new file mode 100644
--- /dev/null
+++ b/toolkit/locales/en-US/toolkit/updates/history.ftl
@@ -0,0 +1,24 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+history-title = Update History
+history-intro = The following updates have been installed
+
+close-button-label =
+    .buttonlabelcancel = Close
+    .title = Update History
+
+no-updates-label = No updates installed yet
+name-header = Update Name
+date-header = Install Date
+type-header = Type
+state-header = State
+
+# Used to display update history
+#
+# Variables:
+#   $name (String): name of the update
+#   $buildID (String): build identifier from the local updates.xml
+update-full-name =
+    .name = { $name } ({ $buildID })
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -93,17 +93,16 @@
   locale/@AB_CD@/mozapps/preferences/preferences.properties       (%chrome/mozapps/preferences/preferences.properties)
   locale/@AB_CD@/mozapps/profile/createProfileWizard.dtd          (%chrome/mozapps/profile/createProfileWizard.dtd)
   locale/@AB_CD@/mozapps/profile/profileSelection.properties      (%chrome/mozapps/profile/profileSelection.properties)
   locale/@AB_CD@/mozapps/profile/profileSelection.dtd             (%chrome/mozapps/profile/profileSelection.dtd)
 #ifndef MOZ_FENNEC
   locale/@AB_CD@/mozapps/update/updates.dtd                       (%chrome/mozapps/update/updates.dtd)
   locale/@AB_CD@/mozapps/update/updates.properties                (%chrome/mozapps/update/updates.properties)
 #endif
-  locale/@AB_CD@/mozapps/update/history.dtd                       (%chrome/mozapps/update/history.dtd)
 % locale pluginproblem @AB_CD@ %locale/@AB_CD@/pluginproblem/
   locale/@AB_CD@/pluginproblem/pluginproblem.dtd                  (%chrome/pluginproblem/pluginproblem.dtd)
 % locale alerts @AB_CD@ %locale/@AB_CD@/alerts/
   locale/@AB_CD@/alerts/alert.dtd                                (%chrome/alerts/alert.dtd)
   locale/@AB_CD@/alerts/alert.properties                         (%chrome/alerts/alert.properties)
 % locale passwordmgr @AB_CD@ %locale/@AB_CD@/passwordmgr/
   locale/@AB_CD@/passwordmgr/passwordmgr.properties (%chrome/passwordmgr/passwordmgr.properties)
   locale/@AB_CD@/passwordmgr/passwordManager.dtd    (%chrome/passwordmgr/passwordManager.dtd)
--- a/toolkit/mozapps/update/content/history.js
+++ b/toolkit/mozapps/update/content/history.js
@@ -15,34 +15,32 @@ var gUpdateHistory = {
     var um =
         Cc["@mozilla.org/updates/update-manager;1"].
         getService(Ci.nsIUpdateManager);
     var uc = um.updateCount;
     if (uc) {
       while (this._view.hasChildNodes())
         this._view.firstChild.remove();
 
-      var bundle = document.getElementById("updateBundle");
-
       for (var i = 0; i < uc; ++i) {
         var update = um.getUpdateAt(i);
 
         if (!update || !update.name)
           continue;
 
         // Don't display updates that are downloading since they don't have
         // valid statusText for the UI (bug 485493).
         if (!update.statusText)
           continue;
 
         var element = document.createXULElement("richlistitem");
         element.className = "update";
         this._view.appendChild(element);
-        element.name = bundle.getFormattedString("updateFullName",
-          [update.name, update.buildID]);
+        element.setAttribute("data-l10n-attrs", "name");
+        document.l10n.setAttributes(element, "update-full-name", { name: update.name, buildID: update.buildID});
         element.installDate = this._formatDate(update.installDate);
         if (update.detailsURL)
           element.detailsURL = update.detailsURL;
         else
           element.hideDetailsURL = true;
         element.status = update.statusText;
       }
     }
--- a/toolkit/mozapps/update/content/history.xul
+++ b/toolkit/mozapps/update/content/history.xul
@@ -1,39 +1,35 @@
 <?xml version="1.0"?>
 
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-<!DOCTYPE dialog [
-<!ENTITY % historyDTD SYSTEM "chrome://mozapps/locale/update/history.dtd">
-<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
-%historyDTD;
-%brandDTD;
-]>
+<!DOCTYPE dialog>
 
 <?xml-stylesheet href="chrome://global/skin/"?>
 <?xml-stylesheet href="chrome://mozapps/content/update/updates.css"?>
 <?xml-stylesheet href="chrome://mozapps/skin/update/updates.css"?>
 
 <dialog id="history" windowtype="Update:History"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         style="width: 35em;"
         buttons="cancel"
         defaultButton="cancel"
-        buttonlabelcancel="&closebutton.label;"
-        title="&history.title;"
+        data-l10n-id="close-button-label"
+        data-l10n-attrs="buttonlabelcancel"
         onload="gUpdateHistory.onLoad();">
 
+  <linkset>
+    <link rel="localization" href="toolkit/updates/history.ftl"/>
+  </linkset>
+
   <script type="application/javascript"
           src="chrome://mozapps/content/update/history.js"/>
 
-  <stringbundle id="updateBundle"
-                src="chrome://mozapps/locale/update/updates.properties"/>
-
-  <label>&history2.intro;</label>
+  <label data-l10n-id="history-intro"></label>
   <separator class="thin"/>
   <richlistbox id="historyItems" flex="1">
-    <label>&noupdates.label;</label>
+    <label data-l10n-id="no-updates-label"></label>
   </richlistbox>
   <separator class="thin"/>
 </dialog>