Bug 1608197 - port createProfileWizard DTD to fluent r=Gijs,fluent-reviewers,flod
authorArtem <salniker@msu.edu>
Tue, 24 Mar 2020 16:35:16 +0000
changeset 520236 154f0e6408f677723b1c9a737cf8f4d2d4b8ea64
parent 520235 df14c69672f093c40d03d7b823ea4bd4e60b54b6
child 520237 53361841567a250c71e6cb849de18d1b4e0894e5
push id37246
push useropoprus@mozilla.com
push dateWed, 25 Mar 2020 03:40:33 +0000
treeherdermozilla-central@14b59d4adc95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, fluent-reviewers, flod
bugs1608197
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1608197 - port createProfileWizard DTD to fluent r=Gijs,fluent-reviewers,flod Differential Revision: https://phabricator.services.mozilla.com/D62867
python/l10n/fluent_migrations/bug_1608197_create_profile_wizard.py
toolkit/content/widgets/wizard.js
toolkit/locales/en-US/chrome/mozapps/profile/createProfileWizard.dtd
toolkit/locales/en-US/toolkit/global/createProfileWizard.ftl
toolkit/locales/jar.mn
toolkit/profile/content/createProfileWizard.xhtml
toolkit/profile/jar.mn
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1608197_create_profile_wizard.py
@@ -0,0 +1,149 @@
+# 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, REPLACE
+from fluent.migrate.helpers import MESSAGE_REFERENCE, TERM_REFERENCE
+
+def migrate(ctx):
+    """Bug 1608197 - Migrate createProfileWizard to Fluent, part {index}."""
+
+    ctx.add_transforms(
+        "toolkit/toolkit/global/createProfileWizard.ftl",
+        "toolkit/toolkit/global/createProfileWizard.ftl",
+    transforms_from(
+"""
+create-profile-window =
+    .title = { COPY(from_path, "newprofile.title") }
+    .style = { COPY(from_path, "window.size") }
+profile-creation-explanation-4 = { PLATFORM() ->
+    [macos] { COPY(from_path, "profileCreationExplanation_4Mac.text") }
+   *[other] { COPY(from_path, "profileCreationExplanation_4.text") }
+  }
+profile-creation-intro = { COPY(from_path, "profileCreationIntro.text") }
+profile-prompt = { COPY(from_path, "profilePrompt.label") }
+    .accesskey = { COPY(from_path, "profilePrompt.accesskey") }
+profile-default-name =
+    .value = { COPY(from_path, "profileDefaultName") }
+profile-directory-explanation = { COPY(from_path, "profileDirectoryExplanation.text") }
+create-profile-choose-folder =
+    .label = { COPY(from_path, "button.choosefolder.label") }
+    .accesskey = { COPY(from_path, "button.choosefolder.accesskey") }
+create-profile-use-default =
+    .label = { COPY(from_path, "button.usedefault.label") }
+    .accesskey = { COPY(from_path, "button.usedefault.accesskey") }
+""", from_path="toolkit/chrome/mozapps/profile/createProfileWizard.dtd"))
+    ctx.add_transforms(
+    "toolkit/toolkit/global/createProfileWizard.ftl",
+    "toolkit/toolkit/global/createProfileWizard.ftl",
+    [
+    FTL.Message(
+        id=FTL.Identifier("create-profile-first-page-header"),
+        value=FTL.Pattern(
+            elements=[
+                FTL.Placeable(
+                    expression=FTL.SelectExpression(
+                        selector=FTL.FunctionReference(
+                            id=FTL.Identifier(name="PLATFORM"),
+                            arguments=FTL.CallArguments(positional=[], named=[])
+                        ),
+                        variants=[
+                            FTL.Variant(
+                                key=FTL.Identifier('macos'),
+                                default=False,
+                                value=COPY(
+                                    "toolkit/chrome/global/wizard.properties",
+                                    "default-first-title-mac",
+                                )
+                            ),
+                            FTL.Variant(
+                                key=FTL.Identifier('other'),
+                                default=True,
+                                value=REPLACE(
+                                    "toolkit/chrome/global/wizard.properties",
+                                    "default-first-title",
+                                    {
+                                        "%1$S": MESSAGE_REFERENCE("create-profile-window.title"),
+                                    },
+                                    normalize_printf=True
+                                )
+                            )
+                        ]
+                    )
+                )
+            ]
+        )
+    ),
+    FTL.Message(
+        id=FTL.Identifier("profile-creation-explanation-1"),
+        value=REPLACE(
+            "toolkit/chrome/mozapps/profile/createProfileWizard.dtd",
+            "profileCreationExplanation_1.text",
+            {
+                "&brandShortName;": TERM_REFERENCE("brand-short-name")
+            }
+        )
+    ),
+    FTL.Message(
+        id=FTL.Identifier("profile-creation-explanation-2"),
+        value=REPLACE(
+            "toolkit/chrome/mozapps/profile/createProfileWizard.dtd",
+            "profileCreationExplanation_2.text",
+            {
+                "&brandShortName;": TERM_REFERENCE("brand-short-name")
+            }
+        )
+    ),
+    FTL.Message(
+        id=FTL.Identifier("profile-creation-explanation-3"),
+        value=REPLACE(
+            "toolkit/chrome/mozapps/profile/createProfileWizard.dtd",
+            "profileCreationExplanation_3.text",
+            {
+                "&brandShortName;": TERM_REFERENCE("brand-short-name")
+            }
+        )
+    ),
+    FTL.Message(
+        id=FTL.Identifier("create-profile-last-page-header"),
+        value=FTL.Pattern(
+            elements=[
+                FTL.Placeable(
+                    expression=FTL.SelectExpression(
+                        selector=FTL.FunctionReference(
+                            id=FTL.Identifier(name="PLATFORM"),
+                            arguments=FTL.CallArguments(positional=[], named=[])
+                        ),
+                        variants=[
+                            FTL.Variant(
+                                key=FTL.Identifier('macos'),
+                                default=False,
+                                value=COPY(
+                                    "toolkit/chrome/global/wizard.properties",
+                                    "default-last-title-mac",
+                                )
+                            ),
+                            FTL.Variant(
+                                key=FTL.Identifier('other'),
+                                default=True,
+                                value=REPLACE(
+                                    "toolkit/chrome/global/wizard.properties",
+                                    "default-last-title",
+                                    {
+                                        "%1$S": MESSAGE_REFERENCE("create-profile-window.title"),
+                                    },
+                                    normalize_printf=True
+                                )
+                            )
+                        ]
+                    )
+                )
+            ]
+        )
+    ),
+    ]
+    )
--- a/toolkit/content/widgets/wizard.js
+++ b/toolkit/content/widgets/wizard.js
@@ -103,16 +103,19 @@
 
     static get inheritedAttributes() {
       return {
         ".wizard-buttons": "pagestep,firstpage,lastpage",
       };
     }
 
     connectedCallback() {
+      if (document.l10n) {
+        document.l10n.connectRoot(this.shadowRoot);
+      }
       document.documentElement.setAttribute("role", "dialog");
       this._maybeStartWizard();
 
       window.addEventListener("close", event => {
         if (this.cancel()) {
           event.preventDefault();
         }
       });
@@ -414,16 +417,20 @@
         this._hasStarted = true;
         this.advance();
         return true;
       }
       return false;
     }
 
     _adjustWizardHeader() {
+      if (document.l10n) {
+        this._adjustFluentHeaders();
+        return;
+      }
       var label = this.currentPage.getAttribute("label");
       if (!label && this.onFirstPage && this._bundle) {
         if (AppConstants.platform == "macosx") {
           label = this._bundle.GetStringFromName("default-first-title-mac");
         } else {
           label = this._bundle.formatStringFromName("default-first-title", [
             this.title,
           ]);
@@ -443,16 +450,27 @@
       let headerDescEl = this._wizardHeader.querySelector(
         ".wizard-header-description"
       );
       if (headerDescEl) {
         headerDescEl.textContent = this.currentPage.getAttribute("description");
       }
     }
 
+    _adjustFluentHeaders() {
+      let value = this.currentPage.getAttribute("data-header-label-id");
+      let label = this._wizardHeader.querySelector(".wizard-header-label");
+      if (value) {
+        document.l10n.setAttributes(label, value);
+      } else {
+        label.removeAttribute("data-l10n-id");
+        label.textContent = "";
+      }
+    }
+
     _hitEnter(evt) {
       if (!evt.defaultPrevented) {
         this.advance();
       }
     }
 
     _fireEvent(aTarget, aType) {
       var event = document.createEvent("Events");
deleted file mode 100644
--- a/toolkit/locales/en-US/chrome/mozapps/profile/createProfileWizard.dtd
+++ /dev/null
@@ -1,25 +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 newprofile.title             "Create Profile Wizard">
-<!ENTITY window.size                  "width: 45em; height: 32em;">
-
-<!-- First wizard page -->
-<!ENTITY profileCreationExplanation_1.text  "&brandShortName; stores information about your settings and preferences in your personal profile.">
-<!ENTITY profileCreationExplanation_2.text  "If you are sharing this copy of &brandShortName; with other users, you can use profiles to keep each user’s information separate. To do this, each user should create his or her own profile.">
-<!ENTITY profileCreationExplanation_3.text  "If you are the only person using this copy of &brandShortName;, you must have at least one profile. If you would like, you can create multiple profiles for yourself to store different sets of settings and preferences. For example, you may want to have separate profiles for business and personal use.">
-<!ENTITY profileCreationExplanation_4.text  "To begin creating your profile, click Next.">
-<!ENTITY profileCreationExplanation_4Mac.text  "To begin creating your profile, click Continue.">
-<!ENTITY profileCreationExplanation_4Gnome.text  "To begin creating your profile, click Next.">
-
-<!-- Second wizard page -->
-<!ENTITY profileCreationIntro.text      "If you create several profiles you can tell them apart by the profile names. You may use the name provided here or use one of your own.">
-<!ENTITY profilePrompt.label            "Enter new profile name:">
-<!ENTITY profilePrompt.accesskey        "E">
-<!ENTITY profileDirectoryExplanation.text   "Your user settings, preferences and other user-related data will be stored in:">
-<!ENTITY profileDefaultName             "Default User">
-<!ENTITY button.choosefolder.label      "Choose Folder…">
-<!ENTITY button.choosefolder.accesskey  "C">
-<!ENTITY button.usedefault.label        "Use Default Folder">
-<!ENTITY button.usedefault.accesskey    "U">
new file mode 100644
--- /dev/null
+++ b/toolkit/locales/en-US/toolkit/global/createProfileWizard.ftl
@@ -0,0 +1,53 @@
+# 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/.
+
+create-profile-window =
+  .title = Create Profile Wizard
+  .style = width: 45em; height: 32em;
+
+## First wizard page
+
+create-profile-first-page-header =
+  { PLATFORM() ->
+    [macos] Introduction
+   *[other] Welcome to the { create-profile-window.title }
+  }
+
+profile-creation-explanation-1 = { -brand-short-name } stores information about your settings and preferences in your personal profile.
+
+profile-creation-explanation-2 = If you are sharing this copy of { -brand-short-name } with other users, you can use profiles to keep each user’s information separate. To do this, each user should create his or her own profile.
+
+profile-creation-explanation-3 = If you are the only person using this copy of { -brand-short-name }, you must have at least one profile. If you would like, you can create multiple profiles for yourself to store different sets of settings and preferences. For example, you may want to have separate profiles for business and personal use.
+
+profile-creation-explanation-4 =
+  { PLATFORM() ->
+    [macos] To begin creating your profile, click Continue.
+   *[other] To begin creating your profile, click Next.
+  }
+
+## Second wizard page
+
+create-profile-last-page-header =
+  { PLATFORM() ->
+    [macos] Conclusion
+   *[other] Completing the { create-profile-window.title }
+  }
+
+profile-creation-intro = If you create several profiles you can tell them apart by the profile names. You may use the name provided here or use one of your own.
+
+profile-prompt = Enter new profile name:
+  .accesskey = E
+
+profile-default-name =
+  .value = Default User
+
+profile-directory-explanation = Your user settings, preferences and other user-related data will be stored in:
+
+create-profile-choose-folder =
+  .label = Choose Folder…
+  .accesskey = C
+
+create-profile-use-default =
+  .label = Use Default Folder
+  .accesskey = U
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -69,17 +69,16 @@
   locale/@AB_CD@/mozapps/downloads/downloads.properties           (%chrome/mozapps/downloads/downloads.properties)
   locale/@AB_CD@/mozapps/extensions/extensions.dtd                (%chrome/mozapps/extensions/extensions.dtd)
 #ifndef MOZ_FENNEC
   locale/@AB_CD@/mozapps/extensions/extensions.properties         (%chrome/mozapps/extensions/extensions.properties)
   locale/@AB_CD@/mozapps/extensions/blocklist.dtd                 (%chrome/mozapps/extensions/blocklist.dtd)
 #endif
   locale/@AB_CD@/mozapps/handling/handling.dtd                    (%chrome/mozapps/handling/handling.dtd)
   locale/@AB_CD@/mozapps/handling/handling.properties             (%chrome/mozapps/handling/handling.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)
 #ifdef MOZ_BLOCK_PROFILE_DOWNGRADE
   locale/@AB_CD@/mozapps/profile/profileDowngrade.dtd             (%chrome/mozapps/profile/profileDowngrade.dtd)
 #endif
 #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
--- a/toolkit/profile/content/createProfileWizard.xhtml
+++ b/toolkit/profile/content/createProfileWizard.xhtml
@@ -1,77 +1,69 @@
 <?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/. -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
-<!DOCTYPE wizard [
-<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
-%brandDTD;
-<!ENTITY % profileDTD SYSTEM "chrome://mozapps/locale/profile/createProfileWizard.dtd">
-%profileDTD;
-]>
+<!DOCTYPE wizard>
 
 <window id="createProfileWizard"
-        title="&newprofile.title;"
+        data-l10n-id="create-profile-window"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="initWizard();"
-        style="&window.size;">
+        data-l10n-attrs="style"
+        >
+
+<linkset>
+  <html:link rel="localization" href="branding/brand.ftl"/>
+  <html:link rel="localization" href="toolkit/global/createProfileWizard.ftl"/>
+</linkset>
 
 <script src="chrome://global/content/customElements.js"/>
 <script src="chrome://global/content/globalOverlay.js"/>
 <script src="chrome://global/content/editMenuOverlay.js"/>
 <script src="chrome://mozapps/content/profile/createProfileWizard.js"/>
 
 <wizard>
   <stringbundle id="bundle_profileManager"
                 src="chrome://mozapps/locale/profile/profileSelection.properties"/>
 
-  <wizardpage id="explanation">
-    <description>&profileCreationExplanation_1.text;</description>
-    <description>&profileCreationExplanation_2.text;</description>
-    <description>&profileCreationExplanation_3.text;</description>
+  <wizardpage id="explanation" data-header-label-id="create-profile-first-page-header">
+    <description data-l10n-id="profile-creation-explanation-1"></description>
+    <description data-l10n-id="profile-creation-explanation-2"></description>
+    <description data-l10n-id="profile-creation-explanation-3"></description>
     <spacer flex="1"/>
-#ifdef XP_MACOSX
-    <description>&profileCreationExplanation_4Mac.text;</description>
-#else
-#ifdef XP_UNIX
-    <description>&profileCreationExplanation_4Gnome.text;</description>
-#else
-    <description>&profileCreationExplanation_4.text;</description>
-#endif
-#endif
+    <description data-l10n-id="profile-creation-explanation-4"></description>
   </wizardpage>
 
-  <wizardpage id="createProfile">
-    <description>&profileCreationIntro.text;</description>
+  <wizardpage id="createProfile" data-header-label-id="create-profile-last-page-header">
+    <description data-l10n-id="profile-creation-intro"></description>
 
-    <label accesskey="&profilePrompt.accesskey;" control="ProfileName">&profilePrompt.label;</label>
-    <html:input id="profileName" value="&profileDefaultName;"
-                oninput="updateProfileName(this.value);"/>
+    <label data-l10n-id="profile-prompt" control="ProfileName"></label>
+    <html:input id="profileName" data-l10n-id="profile-default-name"
+                data-l10n-attrs="value" oninput="updateProfileName(this.value);"/>
 
     <separator/>
 
-    <description>&profileDirectoryExplanation.text;</description>
+    <description data-l10n-id="profile-directory-explanation"></description>
 
     <vbox class="indent" flex="1" style="overflow: auto;">
       <description id="profileDisplay">*</description>
     </vbox>
 
     <hbox>
-      <button label="&button.choosefolder.label;" oncommand="chooseProfileFolder();"
-              accesskey="&button.choosefolder.accesskey;"/>
+      <button data-l10n-id="create-profile-choose-folder" oncommand="chooseProfileFolder();"/>
 
-      <button id="useDefault" label="&button.usedefault.label;"
+      <button id="useDefault" data-l10n-id="create-profile-use-default"
               oncommand="setDisplayToDefaultFolder(); updateProfileDisplay();"
-              accesskey="&button.usedefault.accesskey;" disabled="true"/>
+              disabled="true"/>
     </hbox>
 
     <separator/>
 
     <description id="finishText">*</description>
   </wizardpage>
 
 </wizard>
--- a/toolkit/profile/jar.mn
+++ b/toolkit/profile/jar.mn
@@ -1,13 +1,13 @@
 # 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/.
 
 toolkit.jar:
   content/mozapps/profile/createProfileWizard.js  (content/createProfileWizard.js)
-* content/mozapps/profile/createProfileWizard.xhtml (content/createProfileWizard.xhtml)
+  content/mozapps/profile/createProfileWizard.xhtml (content/createProfileWizard.xhtml)
   content/mozapps/profile/profileSelection.js     (content/profileSelection.js)
   content/mozapps/profile/profileSelection.xhtml  (content/profileSelection.xhtml)
 #ifdef MOZ_BLOCK_PROFILE_DOWNGRADE
   content/mozapps/profile/profileDowngrade.js     (content/profileDowngrade.js)
 * content/mozapps/profile/profileDowngrade.xhtml  (content/profileDowngrade.xhtml)
 #endif