Bug 1451992 - Migrate Preferences::Subdialogs::Colors to Fluent. r=gijs,gandalf draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 05 Apr 2018 03:17:01 +0200
changeset 780750 a4dfcb237bc77d574dd028a8400e183d29c506d5
parent 780601 58aacad6d8e5c3c41a714c0bc0a5995c8b66b827
child 780751 d571eec4f0267560c885e03b5f64cafe33764993
push id106121
push userbmo:gandalf@aviary.pl
push dateThu, 12 Apr 2018 00:27:59 +0000
reviewersgijs, gandalf
bugs1451992
milestone61.0a1
Bug 1451992 - Migrate Preferences::Subdialogs::Colors to Fluent. r=gijs,gandalf MozReview-Commit-ID: KlA7gS9D2W5
browser/components/preferences/colors.xul
browser/components/preferences/in-content/main.xul
browser/components/preferences/in-content/preferences.xul
browser/locales/en-US/browser/preferences/colors.ftl
browser/locales/en-US/chrome/browser/preferences/colors.dtd
browser/locales/jar.mn
python/l10n/fluent_migrations/bug_1451992_preferences_colors.py
--- a/browser/components/preferences/colors.xul
+++ b/browser/components/preferences/colors.xul
@@ -3,105 +3,96 @@
 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 # 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"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
 
-<!DOCTYPE dialog [
-  <!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
-  %preferencesDTD;
-  <!ENTITY % colorsDTD SYSTEM "chrome://browser/locale/preferences/colors.dtd">
-  %colorsDTD;
-]>
-
 <dialog id="ColorsDialog" type="child" class="prefwindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="&colorsDialog.title;"
+        data-l10n-id="colors-window"
+        data-l10n-attrs="title, style"
         buttons="accept,cancel,help"
         persist="lastSelected screenX screenY"
         role="dialog"
         helpTopic="prefs-fonts-and-colors"
-        ondialoghelp="openPrefsHelp()"
-#ifdef XP_MACOSX
-        style="width: &window.macWidth; !important;">
-#else
-        style="width: &window.width; !important;">
-#endif
+        ondialoghelp="openPrefsHelp()">
+
+  <link rel="localization" href="browser/preferences/colors.ftl"/>
+  <script type="application/javascript" src="chrome://global/content/l10n.js"></script>
 
   <script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
   <script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
 
   <keyset>
-    <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
+    <key data-l10n-id="colors-close-key" modifiers="accel" oncommand="Preferences.close(event)"/>
   </keyset>
 
   <vbox id="ColorsDialogPane" class="prefpane">
 
     <script type="application/javascript" src="chrome://browser/content/preferences/colors.js"/>
 
     <hbox>
       <groupbox flex="1">
-        <caption><label>&color;</label></caption>
+        <caption><label data-l10n-id="colors-text-and-background"/></caption>
         <hbox align="center">
-          <label accesskey="&textColor2.accesskey;" control="foregroundtextmenu">&textColor2.label;</label>
+          <label data-l10n-id="colors-text-header" control="foregroundtextmenu"/>
           <spacer flex="1"/>
           <colorpicker type="button" id="foregroundtextmenu" palettename="standard"
                        preference="browser.display.foreground_color"/>
         </hbox>
         <hbox align="center" style="margin-top: 5px">
-          <label accesskey="&backgroundColor2.accesskey;" control="backgroundmenu">&backgroundColor2.label;</label>
+          <label data-l10n-id="colors-background" control="backgroundmenu" />
           <spacer flex="1"/>
           <colorpicker type="button" id="backgroundmenu" palettename="standard"
                        preference="browser.display.background_color"/>
         </hbox>
         <separator class="thin"/>
         <hbox align="center">
-          <checkbox id="browserUseSystemColors" label="&useSystemColors.label;" accesskey="&useSystemColors.accesskey;"
+          <checkbox id="browserUseSystemColors" data-l10n-id="colors-use-system"
                     preference="browser.display.use_system_colors"/>
         </hbox>
       </groupbox>
 
       <groupbox flex="1">
-        <caption><label>&links;</label></caption>
+        <caption><label data-l10n-id="colors-links-header"/></caption>
         <hbox align="center">
-          <label accesskey="&linkColor2.accesskey;" control="unvisitedlinkmenu">&linkColor2.label;</label>
+          <label data-l10n-id="colors-unvisited-links" control="unvisitedlinkmenu" />
           <spacer flex="1"/>
           <colorpicker type="button" id="unvisitedlinkmenu" palettename="standard"
                        preference="browser.anchor_color"/>
         </hbox>
         <hbox align="center" style="margin-top: 5px">
-          <label accesskey="&visitedLinkColor2.accesskey;" control="visitedlinkmenu">&visitedLinkColor2.label;</label>
+          <label data-l10n-id="colors-visited-links" control="visitedlinkmenu" />
           <spacer flex="1"/>
           <colorpicker type="button" id="visitedlinkmenu" palettename="standard"
                        preference="browser.visited_color"/>
         </hbox>
         <separator class="thin"/>
         <hbox align="center">
-          <checkbox id="browserUnderlineAnchors" label="&underlineLinks.label;" accesskey="&underlineLinks.accesskey;"
+          <checkbox id="browserUnderlineAnchors" data-l10n-id="colors-underline-links"
                     preference="browser.underline_anchors"/>
         </hbox>
       </groupbox>
     </hbox>
 #ifdef XP_WIN
     <vbox align="start">
 #else
     <vbox>
 #endif
-      <label accesskey="&overrideDefaultPageColors2.accesskey;"
-             control="useDocumentColors">&overrideDefaultPageColors2.label;</label>
+      <label data-l10n-id="colors-page-override" control="useDocumentColors" />
       <hbox>
         <menulist id="useDocumentColors" preference="browser.display.document_color_use" flex="1">
           <menupopup>
-            <menuitem label="&overrideDefaultPageColors.always.label;"
+            <menuitem data-l10n-id="colors-page-override-option-always"
                       value="2" id="documentColorAlways"/>
-            <menuitem label="&overrideDefaultPageColors.auto.label;"
+            <menuitem data-l10n-id="colors-page-override-option-auto"
                       value="0" id="documentColorAutomatic"/>
-            <menuitem label="&overrideDefaultPageColors.never.label;"
+            <menuitem data-l10n-id="colors-page-override-option-never"
                       value="1" id="documentColorNever"/>
           </menupopup>
         </menulist>
       </hbox>
     </vbox>
   </vbox>
 </dialog>
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -264,28 +264,30 @@
     <hbox id="colorsSettings">
       <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. -->
       <hbox>
         <button id="colors"
                 class="accessory-button"
                 icon="select-color"
                 data-l10n-id="colors-settings"
-                searchkeywords="&overrideDefaultPageColors2.label;
-                                &overrideDefaultPageColors.always.label;
-                                &overrideDefaultPageColors.auto.label;
-                                &overrideDefaultPageColors.never.label;
-                                &color;
-                                &textColor2.label;
-                                &backgroundColor2.label;
-                                &useSystemColors.label;
-                                &underlineLinks.label;
-                                &links;
-                                &linkColor2.label;
-                                &visitedLinkColor2.label;"/>
+                search-l10n-ids="
+                  colors-page-override,
+                  colors-page-override-option-always.label,
+                  colors-page-override-option-auto.label,
+                  colors-page-override-option-never.label,
+                  colors-text-and-background,
+                  colors-text-header,
+                  colors-background,
+                  colors-use-system,
+                  colors-underline-links,
+                  colors-links-header,
+                  colors-unvisited-links,
+                  colors-visited-links
+                "/>
       </hbox>
     </hbox>
   </vbox>
 </groupbox>
 
 <!-- Languages -->
 <groupbox id="languagesGroup" data-category="paneGeneral" hidden="true">
   <caption><label data-l10n-id="language-header"/></caption>
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -17,17 +17,16 @@
 <?xml-stylesheet href="chrome://browser/skin/preferences/in-content/privacy.css"?>
 
 <!DOCTYPE page [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 <!ENTITY % selectBookmarkDTD SYSTEM
   "chrome://browser/locale/preferences/selectBookmark.dtd">
 <!ENTITY % languagesDTD SYSTEM "chrome://browser/locale/preferences/languages.dtd">
 <!ENTITY % fontDTD SYSTEM "chrome://browser/locale/preferences/fonts.dtd">
-<!ENTITY % colorsDTD SYSTEM "chrome://browser/locale/preferences/colors.dtd">
 <!ENTITY % permissionsDTD SYSTEM "chrome://browser/locale/preferences/permissions.dtd">
 <!ENTITY % passwordManagerDTD SYSTEM "chrome://passwordmgr/locale/passwordManager.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 % connectionDTD SYSTEM "chrome://browser/locale/preferences/connection.dtd">
 <!ENTITY % siteDataSettingsDTD SYSTEM
   "chrome://browser/locale/preferences/siteDataSettings.dtd" >
@@ -39,17 +38,16 @@
 <!ENTITY % aboutHomeDTD SYSTEM "chrome://browser/locale/aboutHome.dtd">
 <!ENTITY % contentDTD SYSTEM "chrome://browser/locale/preferences/content.dtd">
 <!ENTITY % aboutDialogDTD SYSTEM "chrome://browser/locale/aboutDialog.dtd" >
 %aboutDialogDTD;
 %brandDTD;
 %selectBookmarkDTD;
 %languagesDTD;
 %fontDTD;
-%colorsDTD;
 %permissionsDTD;
 %passwordManagerDTD;
 %historyDTD;
 %certManagerDTD;
 %deviceManangerDTD;
 %connectionDTD;
 %siteDataSettingsDTD;
 %privacyDTD;
@@ -73,16 +71,17 @@
 
   <link rel="localization" href="branding/brand.ftl"/>
   <link rel="localization" href="browser/branding/sync-brand.ftl"/>
   <link rel="localization" href="browser/preferences/preferences.ftl"/>
 
   <!-- Links below are only used for search-l10n-ids into subdialogs -->
   <link rel="localization" href="browser/preferences/blocklists.ftl"/>
   <link rel="localization" href="browser/preferences/clearSiteData.ftl"/>
+  <link rel="localization" href="browser/preferences/colors.ftl"/>
 
   <script type="text/javascript" src="chrome://global/content/l10n.js"></script>
 
   <html:link rel="shortcut icon"
               href="chrome://browser/skin/settings.svg"/>
 
   <script type="application/javascript"
           src="chrome://browser/content/utilityOverlay.js"/>
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/browser/preferences/colors.ftl
@@ -0,0 +1,48 @@
+# 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/.
+
+colors-window =
+    .title = Colors
+    .style =
+        { PLATFORM() ->
+            [macos] width: 41em
+           *[other] width: 38em
+        }
+
+colors-close-key =
+    .key = w
+
+colors-page-override = Override the colors specified by the page with your selections above
+    .accesskey = O
+
+colors-page-override-option-always =
+    .label = Always
+colors-page-override-option-auto =
+    .label = Only with High Contrast themes
+colors-page-override-option-never =
+    .label = Never
+
+colors-text-and-background = Text and Background
+
+colors-text-header = Text
+    .accesskey = T
+
+colors-background = Background
+    .accesskey = B
+
+colors-use-system =
+    .label = Use system colors
+    .accesskey = s
+
+colors-underline-links =
+    .label = Underline links
+    .accesskey = U
+
+colors-links-header = Link Colors
+
+colors-unvisited-links = Unvisited Links
+    .accesskey = L
+
+colors-visited-links = Visited Links
+    .accesskey = V
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/preferences/colors.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  colorsDialog.title              "Colors">
-<!ENTITY  window.width                    "38em">
-<!ENTITY  window.macWidth                 "41em">
-
-<!ENTITY  overrideDefaultPageColors2.label       "Override the colors specified by the page with your selections above">
-<!ENTITY  overrideDefaultPageColors2.accesskey   "O">
-
-<!ENTITY  overrideDefaultPageColors.always.label "Always">
-<!ENTITY  overrideDefaultPageColors.auto.label   "Only with High Contrast themes">
-<!ENTITY  overrideDefaultPageColors.never.label  "Never">
-
-<!ENTITY  color                           "Text and Background">
-<!ENTITY  textColor2.label                "Text">
-<!ENTITY  textColor2.accesskey            "T">
-<!ENTITY  backgroundColor2.label          "Background">
-<!ENTITY  backgroundColor2.accesskey      "B">
-<!ENTITY  useSystemColors.label           "Use system colors">
-<!ENTITY  useSystemColors.accesskey       "s">
-
-<!ENTITY  underlineLinks.label            "Underline links">
-<!ENTITY  underlineLinks.accesskey        "U">
-<!ENTITY  links                           "Link Colors">
-<!ENTITY  linkColor2.label                "Unvisited Links">
-<!ENTITY  linkColor2.accesskey            "L">
-<!ENTITY  visitedLinkColor2.label         "Visited Links">
-<!ENTITY  visitedLinkColor2.accesskey     "V">
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -51,17 +51,16 @@
     locale/browser/safebrowsing/phishing-afterload-warning-message.dtd (%chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd)
     locale/browser/safebrowsing/report-phishing.dtd                    (%chrome/browser/safebrowsing/report-phishing.dtd)
     locale/browser/safebrowsing/safebrowsing.properties   (%chrome/browser/safebrowsing/safebrowsing.properties)
     locale/browser/feeds/subscribe.dtd              (%chrome/browser/feeds/subscribe.dtd)
     locale/browser/feeds/subscribe.properties       (%chrome/browser/feeds/subscribe.properties)
     locale/browser/migration/migration.dtd         (%chrome/browser/migration/migration.dtd)
     locale/browser/migration/migration.properties  (%chrome/browser/migration/migration.properties)
     locale/browser/preferences/clearSiteData.properties     (%chrome/browser/preferences/clearSiteData.properties)
-    locale/browser/preferences/colors.dtd             (%chrome/browser/preferences/colors.dtd)
     locale/browser/preferences/connection.dtd         (%chrome/browser/preferences/connection.dtd)
     locale/browser/preferences/content.dtd            (%chrome/browser/preferences/content.dtd)
     locale/browser/preferences/fonts.dtd              (%chrome/browser/preferences/fonts.dtd)
     locale/browser/preferences/languages.dtd          (%chrome/browser/preferences/languages.dtd)
     locale/browser/preferences/main.dtd               (%chrome/browser/preferences/main.dtd)
     locale/browser/preferences/permissions.dtd        (%chrome/browser/preferences/permissions.dtd)
     locale/browser/preferences/preferences.properties     (%chrome/browser/preferences/preferences.properties)
     locale/browser/preferences/privacy.dtd            (%chrome/browser/preferences/privacy.dtd)
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1451992_preferences_colors.py
@@ -0,0 +1,249 @@
+# 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 MESSAGE_REFERENCE
+from fluent.migrate import COPY, CONCAT, REPLACE
+
+def migrate(ctx):
+    """Bug 1451992 - Migrate Preferences::Subdialogs::Colors to Fluent, part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/preferences/colors.ftl',
+        'browser/browser/preferences/colors.ftl',
+        [
+            FTL.Message(
+                id=FTL.Identifier('colors-window'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('title'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'colorsDialog.title'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('style'),
+                        FTL.Pattern(
+                            elements=[
+                                FTL.Placeable(
+                                    expression=FTL.SelectExpression(
+                                        expression=FTL.CallExpression(
+                                            callee=FTL.Function('PLATFORM')
+                                        ),
+                                        variants=[
+                                            FTL.Variant(
+                                                key=FTL.VariantName('macos'),
+                                                default=False,
+                                                value=CONCAT(
+                                                    FTL.TextElement('width: '),
+                                                    COPY(
+                                                        'browser/chrome/browser/preferences/colors.dtd',
+                                                        'window.macWidth'
+                                                    )
+                                                )
+                                            ),
+                                            FTL.Variant(
+                                                key=FTL.VariantName('other'),
+                                                default=True,
+                                                value=CONCAT(
+                                                    FTL.TextElement('width: '),
+                                                    COPY(
+                                                        'browser/chrome/browser/preferences/colors.dtd',
+                                                        'window.width'
+                                                    )
+                                                )
+                                            )
+                                        ]
+                                    )
+                                )
+                            ]
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-close-key'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('key'),
+                        COPY(
+                            'toolkit/chrome/global/preferences.dtd',
+                            'windowClose.key'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-page-override'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'overrideDefaultPageColors2.label'
+                ),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'overrideDefaultPageColors2.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-page-override-option-always'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'overrideDefaultPageColors.always.label'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-page-override-option-auto'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'overrideDefaultPageColors.auto.label'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-page-override-option-never'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'overrideDefaultPageColors.never.label'
+                        ),
+                    ),
+                ],
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-text-and-background'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'color'
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-text-header'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'textColor2.label'
+                ),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'textColor2.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-background'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'backgroundColor2.label'
+                ),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'backgroundColor2.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-use-system'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'useSystemColors.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'useSystemColors.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-underline-links'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'underlineLinks.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'underlineLinks.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-links-header'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'links'
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-unvisited-links'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'linkColor2.label'
+                ),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'linkColor2.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('colors-visited-links'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/colors.dtd',
+                    'visitedLinkColor2.label'
+                ),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/colors.dtd',
+                            'visitedLinkColor2.accesskey'
+                        )
+                    )
+                ]
+            )
+        ]
+    )