Bug 1505846 Migrate about:searchreset to Fluent r=jaws,flod,zbraniecki
authorCollin Wing <masterkrombi@gmail.com>
Mon, 26 Nov 2018 17:05:18 +0000
changeset 505433 dc8bec8f0dc03d4bd05c96eb660faa64ef19a9b5
parent 505432 40c896fd483b1943e2bf0fd45b0a003b0874fd31
child 505434 6303d5293c216dd7135201e9eb654c3b8197d9d4
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, flod, zbraniecki
bugs1505846
milestone65.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 1505846 Migrate about:searchreset to Fluent r=jaws,flod,zbraniecki Differential Revision: https://phabricator.services.mozilla.com/D11373
browser/components/search/content/searchReset.js
browser/components/search/content/searchReset.xhtml
browser/locales/en-US/browser/aboutSearchReset.ftl
browser/locales/en-US/chrome/browser/aboutSearchReset.dtd
browser/locales/jar.mn
python/l10n/fluent_migrations/bug_1505846_aboutsearchreset.py
--- a/browser/components/search/content/searchReset.js
+++ b/browser/components/search/content/searchReset.js
@@ -10,19 +10,21 @@ const TELEMETRY_RESULT_ENUM = {
   RESTORED_DEFAULT: 0,
   KEPT_CURRENT: 1,
   CHANGED_ENGINE: 2,
   CLOSED_PAGE: 3,
   OPENED_SETTINGS: 4,
 };
 
 window.onload = function() {
-  let defaultEngine = document.getElementById("defaultEngine");
+  let defaultEngineParagraph = document.getElementById("defaultEngineParagraph");
   let originalDefault = Services.search.originalDefaultEngine;
-  defaultEngine.textContent = originalDefault.name;
+  document.l10n.setAttributes(defaultEngineParagraph, "page-info-new-search-engine",
+                              { searchEngine: originalDefault.name });
+  let defaultEngine = document.getElementById("defaultEngine");
   defaultEngine.style.backgroundImage =
     'url("' + originalDefault.iconURI.spec + '")';
 
   document.getElementById("searchResetChangeEngine").focus();
   window.addEventListener("unload", recordPageClosed);
   document.getElementById("linkSettingsPage")
           .addEventListener("click", openingSettings);
 };
--- a/browser/components/search/content/searchReset.xhtml
+++ b/browser/components/search/content/searchReset.xhtml
@@ -1,61 +1,56 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!-- 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 html [
-  <!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
-  %htmlDTD;
-  <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
-  %globalDTD;
-  <!ENTITY % searchresetDTD SYSTEM "chrome://browser/locale/aboutSearchReset.dtd">
-  %searchresetDTD;
-  <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
-  %brandDTD;
-]>
+<!DOCTYPE html>
 
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <head>
-    <title>&searchreset.tabtitle;</title>
+    <title data-l10n-id="tab-title"/>
     <link rel="stylesheet" type="text/css" media="all"
           href="chrome://global/skin/in-content/info-pages.css"/>
     <link rel="stylesheet" type="text/css" media="all"
           href="chrome://browser/skin/searchReset.css"/>
     <link rel="icon" type="image/png"
           href="chrome://browser/skin/favicon-search-16.svg"/>
 
     <script type="application/javascript"
             src="chrome://browser/content/search/searchReset.js"/>
+    <link rel="localization" href="browser/aboutSearchReset.ftl"/>
+    <link rel="localization" href="branding/brand.ftl"/>
   </head>
 
-  <body dir="&locale.dir;">
+  <body>
 
     <div class="container">
       <div class="title">
-        <h1 class="title-text">&searchreset.pageTitle;</h1>
+        <h1 class="title-text" data-l10n-id="page-title"/>
       </div>
 
       <div class="description">
-        <p>&searchreset.pageInfo1;</p>
-        <p>&searchreset.selector.label;<span id="defaultEngine"/></p>
+        <p data-l10n-id="page-info-outofdate"/>
+        <p id="defaultEngineParagraph">
+          <span id="defaultEngine" data-l10n-name="default-engine"/>
+        </p>
 
-        <p>&searchreset.beforelink.pageInfo2;<a id="linkSettingsPage" href="about:preferences#search">&searchreset.link.pageInfo2;</a>&searchreset.afterlink.pageInfo2;</p>
+        <p data-l10n-id="page-info-how-to-change">
+          <a id="linkSettingsPage" href="about:preferences#search" data-l10n-name="link"></a>
+        </p>
       </div>
 
       <div class="button-container">
         <xul:button id="searchResetKeepCurrent"
-                    label="&searchreset.noChangeButton;"
-                    accesskey="&searchreset.noChangeButton.access;"
+                    data-l10n-id="no-change-button"
                     oncommand="keepCurrentEngine();"/>
         <xul:button class="primary"
                     id="searchResetChangeEngine"
-                    label="&searchreset.changeEngineButton;"
-                    accesskey="&searchreset.changeEngineButton.access;"
+                    data-l10n-id="change-engine-button"
                     oncommand="changeSearchEngine();"/>
       </div>
     </div>
 
   </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/browser/aboutSearchReset.ftl
@@ -0,0 +1,17 @@
+# 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/.
+
+tab-title = Restore Search Settings
+page-title = Restore your search settings?
+page-info-outofdate = Your search settings might be out-of-date. { -brand-short-name } can help you restore the default search settings.
+# Variables:
+#   $searchEngine (String) - Name of the default search engine e.g. Google
+page-info-new-search-engine = This will set your default search engine to <span data-l10n-name="default-engine">{ $searchEngine }</span>
+page-info-how-to-change = You can change these settings at any time from the <a data-l10n-name="link">Settings page</a>.
+no-change-button =
+    .label = Don’t Change
+    .accesskey = D
+change-engine-button =
+    .label = Change Search Engine
+    .accesskey = C
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/aboutSearchReset.dtd
+++ /dev/null
@@ -1,30 +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 searchreset.tabtitle       "Restore Search Settings">
-
-<!ENTITY searchreset.pageTitle      "Restore your search settings?">
-
-<!ENTITY searchreset.pageInfo1      "Your search settings might be out-of-date. &brandShortName; can help you restore the default search settings.">
-
-
-<!-- LOCALIZATION NOTE (searchreset.selector.label): this string is
-followed by a dropdown of all the built-in search engines. -->
-<!ENTITY searchreset.selector.label "This will set your default search engine to">
-
-<!-- LOCALIZATION NOTE (searchreset.beforelink.pageInfo,
-searchreset.afterlink.pageInfo): these two string are used respectively
-before and after the "Settings page" link (searchreset.link.pageInfo2).
-Localizers can use one of them, or both, to better adapt this sentence to
-their language. -->
-<!ENTITY searchreset.beforelink.pageInfo2 "You can change these settings at any time from the ">
-<!ENTITY searchreset.afterlink.pageInfo2  ".">
-
-<!ENTITY searchreset.link.pageInfo2       "Settings page">
-
-<!ENTITY searchreset.noChangeButton        "Don’t Change">
-<!ENTITY searchreset.noChangeButton.access "D">
-
-<!ENTITY searchreset.changeEngineButton        "Change Search Engine">
-<!ENTITY searchreset.changeEngineButton.access "C">
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -12,17 +12,16 @@
 
 @AB_CD@.jar:
 % locale browser @AB_CD@ %locale/browser/
 # bookmarks.html is produced by LOCALIZED_GENERATED_FILES.
     locale/browser/bookmarks.html                  (bookmarks.html)
     locale/browser/aboutPrivateBrowsing.dtd        (%chrome/browser/aboutPrivateBrowsing.dtd)
     locale/browser/aboutRobots.dtd                 (%chrome/browser/aboutRobots.dtd)
     locale/browser/accounts.properties             (%chrome/browser/accounts.properties)
-    locale/browser/aboutSearchReset.dtd            (%chrome/browser/aboutSearchReset.dtd)
     locale/browser/aboutTabCrashed.dtd             (%chrome/browser/aboutTabCrashed.dtd)
     locale/browser/browser.dtd                     (%chrome/browser/browser.dtd)
     locale/browser/baseMenuOverlay.dtd             (%chrome/browser/baseMenuOverlay.dtd)
     locale/browser/browser.properties              (%chrome/browser/browser.properties)
     locale/browser/customizableui/customizableWidgets.properties (%chrome/browser/customizableui/customizableWidgets.properties)
     locale/browser/lightweightThemes.properties    (%chrome/browser/lightweightThemes.properties)
     locale/browser/uiDensity.properties            (%chrome/browser/uiDensity.properties)
     locale/browser/pageInfo.dtd                    (%chrome/browser/pageInfo.dtd)
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1505846_aboutsearchreset.py
@@ -0,0 +1,111 @@
+# 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.helpers import TERM_REFERENCE
+from fluent.migrate import COPY
+from fluent.migrate import REPLACE
+from fluent.migrate import CONCAT
+
+def migrate(ctx):
+    """Bug 1505846 Migrate about:searchreset to Fluent, part {index} """
+
+    ctx.add_transforms(
+
+        "browser/browser/aboutSearchReset.ftl",
+        "browser/browser/aboutSearchReset.ftl",
+        transforms_from(
+"""
+tab-title = { COPY("browser/chrome/browser/aboutSearchReset.dtd", "searchreset.tabtitle") }
+page-title = { COPY("browser/chrome/browser/aboutSearchReset.dtd", "searchreset.pageTitle") }
+"""
+        )
+    )
+
+    ctx.add_transforms(
+        "browser/browser/aboutSearchReset.ftl",
+        "browser/browser/aboutSearchReset.ftl",
+        [
+            FTL.Message(
+                id=FTL.Identifier("page-info-outofdate"),
+                value=REPLACE(
+                    "browser/chrome/browser/aboutSearchReset.dtd",
+                    "searchreset.pageInfo1",
+                    {
+                        "&brandShortName;": TERM_REFERENCE("-brand-short-name"),
+                    }
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier("page-info-how-to-change"),
+                value=CONCAT(
+                    COPY(
+                        "browser/chrome/browser/aboutSearchReset.dtd",
+                        "searchreset.beforelink.pageInfo2",
+                    ),
+                    FTL.TextElement('<a data-l10n-name="link">'),
+                    COPY(
+                        "browser/chrome/browser/aboutSearchReset.dtd",
+                        "searchreset.link.pageInfo2",
+                    ),
+                    FTL.TextElement("</a>"),
+                    COPY(
+                        "browser/chrome/browser/aboutSearchReset.dtd",
+                        "searchreset.afterlink.pageInfo2",
+                    )
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier("no-change-button"),
+                attributes=[
+                    FTL.Attribute(
+                        id=FTL.Identifier("label"),
+                        value=COPY(
+                            "browser/chrome/browser/aboutSearchReset.dtd",
+                            "searchreset.noChangeButton",
+                        )
+                    ),
+                    FTL.Attribute(
+                        id=FTL.Identifier("accesskey"),
+                        value=COPY(
+                            "browser/chrome/browser/aboutSearchReset.dtd",
+                            "searchreset.noChangeButton.access",
+                        )
+                    ),
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier("change-engine-button"),
+                attributes=[
+                    FTL.Attribute(
+                        id=FTL.Identifier("label"),
+                        value=COPY(
+                            "browser/chrome/browser/aboutSearchReset.dtd",
+                            "searchreset.changeEngineButton",
+                        )
+                    ),
+                    FTL.Attribute(
+                        id=FTL.Identifier("accesskey"),
+                        value=COPY(
+                            "browser/chrome/browser/aboutSearchReset.dtd",
+                            "searchreset.changeEngineButton.access",
+                        )
+                    ),
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier("page-info-new-search-engine"),
+                value=CONCAT(
+                    COPY(
+                        "browser/chrome/browser/aboutSearchReset.dtd",
+                        "searchreset.selector.label",
+                    ),
+                    FTL.TextElement(' <span data-l10n-name="default-engine">{ $searchEngine }</span>'),
+                )
+            )
+        ]
+    )