Bug 1517508 - Migrate aboutRobots.dtd to Fluent. r=Gijs,flod
authorJared Wein <jwein@mozilla.com>
Mon, 28 Jan 2019 22:31:09 +0000
changeset 455715 a84968e6ae556298fea0b9923694815df2fc5d5e
parent 455714 8d0ab7804a7c59d4665ace445b2108513cb1c709
child 455716 f4f498ac358d105b86c8603c37106a286df1780a
push id76947
push userjwein@mozilla.com
push dateMon, 28 Jan 2019 22:32:52 +0000
treeherderautoland@a84968e6ae55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, flod
bugs1517508
milestone66.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 1517508 - Migrate aboutRobots.dtd to Fluent. r=Gijs,flod Differential Revision: https://phabricator.services.mozilla.com/D15661
browser/base/content/aboutRobots.xhtml
browser/base/content/test/general/browser_e10s_switchbrowser.js
browser/locales/en-US/browser/aboutRobots.ftl
browser/locales/en-US/chrome/browser/aboutRobots.dtd
browser/locales/jar.mn
python/l10n/fluent_migrations/bug_1517508_aboutRobots.py
--- a/browser/base/content/aboutRobots.xhtml
+++ b/browser/base/content/aboutRobots.xhtml
@@ -4,73 +4,68 @@
    - 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 % netErrorDTD
-    SYSTEM "chrome://global/locale/netError.dtd">
-  %netErrorDTD;
-  <!ENTITY % globalDTD
-    SYSTEM "chrome://global/locale/global.dtd">
-  %globalDTD;
-  <!ENTITY % aboutrobotsDTD
-    SYSTEM "chrome://browser/locale/aboutRobots.dtd">
-  %aboutrobotsDTD;
 ]>
 
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="Content-Security-Policy" content="default-src chrome:" />
-    <title>&robots.pagetitle;</title>
+    <title data-l10n-id="page-title"></title>
     <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
     <link rel="icon" type="image/png" id="favicon" href="chrome://browser/content/robot.ico"/>
     <link rel="stylesheet" href="chrome://browser/content/aboutRobots.css" type="text/css"/>
+    <linkset>
+      <link rel="localization" href="browser/aboutRobots.ftl"/>
+    </linkset>
   </head>
 
-  <body dir="&locale.dir;">
+  <body>
 
     <!-- PAGE CONTAINER (for styling purposes only) -->
     <div id="errorPageContainer">
 
       <!-- Error Title -->
       <div id="errorTitle">
-        <h1 id="errorTitleText">&robots.errorTitleText;</h1>
+        <h1 id="errorTitleText" data-l10n-id="error-title-text"></h1>
       </div>
 
       <!-- LONG CONTENT (the section most likely to require scrolling) -->
       <div id="errorLongContent">
 
         <!-- Short Description -->
         <div id="errorShortDesc">
-          <p id="errorShortDescText">&robots.errorShortDescText;</p>
+          <p id="errorShortDescText" data-l10n-id="error-short-desc-text"></p>
         </div>
 
         <!-- Long Description (Note: See netError.dtd for used XHTML tags) -->
         <div id="errorLongDesc">
           <ul>
-            <li>&robots.errorLongDesc1;</li>
-            <li>&robots.errorLongDesc2;</li>
-            <li>&robots.errorLongDesc3;</li>
-            <li>&robots.errorLongDesc4;</li>
+            <li data-l10n-id="error-long-desc1"></li>
+            <li data-l10n-id="error-long-desc2"></li>
+            <li data-l10n-id="error-long-desc3"></li>
+            <li data-l10n-id="error-long-desc4"></li>
           </ul>
         </div>
 
         <!-- Short Description -->
         <div id="errorTrailerDesc">
-          <p id="errorTrailerDescText">&robots.errorTrailerDescText;</p>
+          <p id="errorTrailerDescText" data-l10n-id="error-trailer-desc-text"></p>
         </div>
 
       </div>
 
       <!-- Button -->
       <button id="errorTryAgain"
-              label2="&robots.dontpress;">&retry.label;</button>
+              data-l10n-id="error-try-again"
+              data-l10n-attrs="label2"></button>
 
       <img id="widget1" src="chrome://browser/content/aboutRobots-widget-left.png"/>
       <img id="widget2" src="chrome://browser/content/aboutRobots-widget-left.png"/>
     </div>
   </body>
   <script type="application/javascript" src="chrome://browser/content/aboutRobots.js"/>
 </html>
--- a/browser/base/content/test/general/browser_e10s_switchbrowser.js
+++ b/browser/base/content/test/general/browser_e10s_switchbrowser.js
@@ -43,17 +43,17 @@ var check_history = async function() {
   let sessionHistory = await get_remote_history(gBrowser.selectedBrowser);
 
   let count = sessionHistory.entries.length;
   is(count, gExpectedHistory.entries.length, "Should have the right number of history entries");
   is(sessionHistory.index, gExpectedHistory.index, "Should have the right history index");
 
   for (let i = 0; i < count; i++) {
     let entry = sessionHistory.entries[i];
-    info("Checking History Entry:", entry.uri);
+    info("Checking History Entry: " + entry.uri);
     is(entry.uri, gExpectedHistory.entries[i].uri, "Should have the right URI");
     is(entry.title, gExpectedHistory.entries[i].title, "Should have the right title");
   }
 };
 
 function clear_history() {
   gExpectedHistory.index = -1;
   gExpectedHistory.entries = [];
@@ -132,16 +132,18 @@ add_task(async function test_navigation(
   await waitForLoad("http://example.com/" + DUMMY_PATH);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
   is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same");
   await check_history();
 
   info("3");
   // Load a non-remote page
   await waitForLoad("about:robots");
+  await TestUtils.waitForCondition(() => gBrowser.selectedBrowser.contentTitle != "about:robots",
+    "Waiting for about:robots title to update");
   is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct");
   is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same");
   await check_history();
 
   info("4");
   // Load a remote page
   await waitForLoad("http://example.org/" + DUMMY_PATH);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
@@ -235,28 +237,32 @@ add_task(async function test_synchronous
 // normal loads
 add_task(async function test_loadflags() {
   let expectedRemote = gMultiProcessBrowser;
 
   info("1");
   // Create a tab and load a remote page in it
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   await waitForLoadWithFlags("about:robots");
+  await TestUtils.waitForCondition(() => gBrowser.selectedBrowser.contentTitle != "about:robots",
+    "Waiting for about:robots title to update");
   is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct");
   await check_history();
 
   info("2");
   // Load a page in the remote process with some custom flags
   await waitForLoadWithFlags("http://example.com/" + DUMMY_PATH, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
   await check_history();
 
   info("3");
   // Load a non-remote page
   await waitForLoadWithFlags("about:robots");
+  await TestUtils.waitForCondition(() => gBrowser.selectedBrowser.contentTitle != "about:robots",
+    "Waiting for about:robots title to update");
   is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct");
   await check_history();
 
   info("4");
   // Load another remote page
   await waitForLoadWithFlags("http://example.org/" + DUMMY_PATH, Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
   await check_history();
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/browser/aboutRobots.ftl
@@ -0,0 +1,28 @@
+# 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/.
+
+### These strings are used in the about:robots page, which ties in with the
+### robots theme used in the Firefox 3 Beta 2/3 first run pages.
+### They're just meant to be fun and whimsical, with references to some geeky
+### but well-known robots in movies and books. Be creative with translations!
+
+# Nonsense line from the movie "The Day The Earth Stood Still". No translation needed.
+page-title = Gort! Klaatu barada nikto!
+# Movie: Logan's Run... Box (cyborg): "Welcome Humans! I am ready for you."
+error-title-text = Welcome Humans!
+# Movie: The Day The Earth Stood Still. Spoken by Klaatu.
+error-short-desc-text = We have come to visit you in peace and with goodwill!
+# Various books by Isaac Asimov. http://en.wikipedia.org/wiki/Three_Laws_of_Robotics
+error-long-desc1 = Robots may not injure a human being or, through inaction, allow a human being to come to harm.
+# Movie: Blade Runner. Batty: "I've seen things you people wouldn’t believe..."
+error-long-desc2 = Robots have seen things you people wouldn’t believe.
+# Book: Hitchhiker’s Guide To The Galaxy. What the Sirius Cybernetics Corporation calls robots.
+error-long-desc3 = Robots are Your Plastic Pal Who’s Fun To Be With.
+# TV: Futurama. Bender's first line is "Bite my shiny metal ass."
+error-long-desc4 = Robots have shiny metal posteriors which should not be bitten.
+# TV: Battlestar Galactica (2004 series). From the opening text.
+error-trailer-desc-text = And they have a plan.
+# Book: Hitchhiker's Guide To The Galaxy. Arthur presses a button and it warns him.
+error-try-again = Try Again
+    .label2 = Please do not press this button again.
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/aboutRobots.dtd
+++ /dev/null
@@ -1,29 +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/. -->
-
-<!-- These strings are used in the about:robots page, which ties in with the
-     robots theme used in the Firefox 3 Beta 2/3 first run pages.
-     They're just meant to be fun and whimsical, with references to some geeky
-     but well-known robots in movies and books. Be creative with translations! -->
-
-<!-- Nonsense line from the movie "The Day The Earth Stood Still". No translation needed. -->
-<!ENTITY robots.pagetitle  "Gort! Klaatu barada nikto!">
-<!-- Movie: Logan's Run... Box (cybog): "Welcome Humans! I am ready for you." -->
-<!ENTITY robots.errorTitleText "Welcome Humans!">
-<!-- Movie: The Day The Earth Stood Still. Spoken by Klaatu. -->
-<!ENTITY robots.errorShortDescText "We have come to visit you in peace and with goodwill!">
-<!-- Various books by Isaac Asimov. http://en.wikipedia.org/wiki/Three_Laws_of_Robotics -->
-<!ENTITY robots.errorLongDesc1 "Robots may not injure a human being or, through inaction, allow a human being to come to harm.">
-<!-- Movie: Blade Runner. Batty: "I've seen things you people wouldn’t believe..." -->
-<!ENTITY robots.errorLongDesc2 "Robots have seen things you people wouldn’t believe.">
-<!-- Book: Hitchhiker’s Guide To The Galaxy. What the Sirius Cybernetics Corporation calls robots. -->
-<!ENTITY robots.errorLongDesc3 "Robots are Your Plastic Pal Who’s Fun To Be With.">
-<!-- TV: Futurama. Bender's first line is "Bite my shiny metal ass." -->
-<!ENTITY robots.errorLongDesc4 "Robots have shiny metal posteriors which should not be bitten.">
-<!-- TV: Battlestar Galactica (2004 series). From the opening text. -->
-<!ENTITY robots.errorTrailerDescText "And they have a plan.">
-<!-- TV: Battlestar Galactica (2004 series). Common expletive referring to Cylons. -->
-<!ENTITY robots.imgtitle "Frakkin' Toasters">
-<!-- Book: Hitchhiker's Guide To The Galaxy. Arthur presses a button and it warns him. -->
-<!ENTITY robots.dontpress "Please do not press this button again.">
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -10,17 +10,16 @@
 [localization] @AB_CD@.jar:
   browser                                          (%browser/**/*.ftl)
 
 @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/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)
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1517508_aboutRobots.py
@@ -0,0 +1,30 @@
+# 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
+
+def migrate(ctx):
+    """Bug 1517508 - Migrate about:robots to use Fluent for localization, part {index}."""
+
+    ctx.add_transforms(
+        "browser/browser/aboutRobots.ftl",
+        "browser/browser/aboutRobots.ftl",
+        transforms_from(
+"""
+page-title = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.pagetitle") }
+error-title-text = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorTitleText") }
+error-short-desc-text = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorShortDescText") }
+error-long-desc1 = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorLongDesc1") }
+error-long-desc2 = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorLongDesc2") }
+error-long-desc3 = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorLongDesc3") }
+error-long-desc4 = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorLongDesc4") }
+error-trailer-desc-text = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.errorTrailerDescText") }
+error-try-again = { COPY("browser/chrome/overrides/netError.dtd", "retry.label") }
+    .label2 = { COPY("browser/chrome/browser/aboutRobots.dtd", "robots.dontpress") }
+""")
+)