Bug 1451992 - Migrate Preferences::Subdialogs::Languages to Fluent. r?gijs,flod draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 05 Apr 2018 21:43:11 +0200
changeset 780605 b81195b8b88074bd278cac98939659b42f92e0d8
parent 780604 798f0756e389cb64154a58ade88bdd0c5595d129
child 780606 d6c198cde97b85e5b581076288ca502e63affbdb
push id106035
push userbmo:gandalf@aviary.pl
push dateWed, 11 Apr 2018 15:42:00 +0000
reviewersgijs, flod
bugs1451992
milestone61.0a1
Bug 1451992 - Migrate Preferences::Subdialogs::Languages to Fluent. r?gijs,flod MozReview-Commit-ID: 96C1P3ZbJeH
browser/components/preferences/in-content/main.xul
browser/components/preferences/in-content/preferences.xul
browser/components/preferences/languages.js
browser/components/preferences/languages.xul
browser/locales/en-US/browser/preferences/languages.ftl
browser/locales/en-US/chrome/browser/preferences/languages.dtd
browser/locales/jar.mn
python/l10n/fluent_migrations/bug_1451992_preferences_languages.py
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -296,23 +296,25 @@
 
   <hbox id="languagesBox" align="center">
     <description flex="1" control="chooseLanguage" data-l10n-id="choose-language-description"/>
     <!-- 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="chooseLanguage"
               class="accessory-button"
               data-l10n-id="choose-button"
-              searchkeywords="&languages.customize.Header;
-                              &languages.customize2.description;
-                              &languages.customize.moveUp.label;
-                              &languages.customize.moveDown.label;
-                              &languages.customize.deleteButton.label;
-                              &languages.customize.selectLanguage.label;
-                              &languages.customize.addButton.label;"/>
+              search-l10n-ids="
+                languages-window.title,
+                languages-description,
+                languages-customize-moveup.label,
+                languages-customize-movedown.label,
+                languages-customize-remove.label,
+                languages-customize-select-language.label,
+                languages-customize-add.label,
+              " />
     </hbox>
   </hbox>
 
   <hbox id="translationBox" hidden="true">
     <hbox align="center" flex="1">
       <checkbox id="translate" preference="browser.translation.detectLanguage"
                 data-l10n-id="translate-web-pages"
                 onsyncfrompreference="return gMainPane.updateButtons('translateButton',
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -15,17 +15,16 @@
 <?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 % selectBookmarkDTD SYSTEM
   "chrome://browser/locale/preferences/selectBookmark.dtd">
-<!ENTITY % languagesDTD SYSTEM "chrome://browser/locale/preferences/languages.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 % siteDataSettingsDTD SYSTEM
   "chrome://browser/locale/preferences/siteDataSettings.dtd" >
 <!ENTITY % privacyDTD SYSTEM "chrome://browser/locale/preferences/privacy.dtd">
@@ -33,17 +32,16 @@
 <!ENTITY % syncDTD SYSTEM "chrome://browser/locale/preferences/sync.dtd">
 <!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
 <!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;
 %permissionsDTD;
 %passwordManagerDTD;
 %historyDTD;
 %certManagerDTD;
 %deviceManangerDTD;
 %siteDataSettingsDTD;
 %privacyDTD;
 %syncBrandDTD;
@@ -68,16 +66,17 @@
   <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"/>
   <link rel="localization" href="browser/preferences/connection.ftl"/>
   <link rel="localization" href="browser/preferences/fonts.ftl"/>
+  <link rel="localization" href="browser/preferences/languages.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"/>
--- a/browser/components/preferences/languages.js
+++ b/browser/components/preferences/languages.js
@@ -107,16 +107,17 @@ var gLanguagesDialog = {
       if (this._availableLanguagesList[i].isVisible &&
           (!(abCD in this._acceptLanguages) || !this._acceptLanguages[abCD])) {
         var menuitem = document.createElement("menuitem");
         menuitem.id = this._availableLanguagesList[i].abcd;
         availableLanguagesPopup.appendChild(menuitem);
         menuitem.setAttribute("label", this._availableLanguagesList[i].name);
       }
     }
+    this._availableLanguages.setAttribute("label", this._availableLanguages.getAttribute("placeholder"));
   },
 
   readAcceptLanguages() {
     while (this._activeLanguages.hasChildNodes())
       this._activeLanguages.firstChild.remove();
 
     var selectedIndex = 0;
     var preference = Preferences.get("intl.accept_languages");
@@ -182,18 +183,16 @@ var gLanguagesDialog = {
       preference.value = arrayOfPrefs.join(",");
     }
 
     this._acceptLanguages[selectedID] = true;
     this._availableLanguages.selectedItem = null;
 
     // Rebuild the available list with the added item removed...
     this._buildAvailableLanguageList();
-
-    this._availableLanguages.setAttribute("label", this._availableLanguages.getAttribute("label2"));
   },
 
   removeLanguage() {
     // Build the new preference value string.
     var languagesArray = [];
     for (var i = 0; i < this._activeLanguages.childNodes.length; ++i) {
       var item = this._activeLanguages.childNodes[i];
       if (!item.selected)
--- a/browser/components/preferences/languages.xul
+++ b/browser/components/preferences/languages.xul
@@ -1,54 +1,50 @@
 <?xml version="1.0"?>
 
 <!-- -*- 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/. -->
 
-<!DOCTYPE dialog [
-  <!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
-  %preferencesDTD;
-  <!ENTITY % languagesDTD SYSTEM "chrome://browser/locale/preferences/languages.dtd">
-  %languagesDTD;
-]>
-
 <?xml-stylesheet href="chrome://global/skin/"?>
 <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
 
 <dialog id="LanguagesDialog" type="child" class="prefwindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="&languages.customize.Header;"
+        data-l10n-id="languages-window"
+        data-l10n-attrs="title, style"
         buttons="accept,cancel,help"
         persist="lastSelected screenX screenY"
         role="dialog"
         onload="gLanguagesDialog.init();"
         helpTopic="prefs-languages"
-        ondialoghelp="openPrefsHelp()"
-        style="width: &window.width;">
+        ondialoghelp="openPrefsHelp()">
+
+  <link rel="localization" href="browser/preferences/languages.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"/>
   <script type="application/javascript" src="chrome://browser/content/preferences/languages.js"/>
 
   <keyset>
-    <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
+    <key data-l10n-id="languages-close-key" modifiers="accel" oncommand="Preferences.close(event)"/>
   </keyset>
 
   <vbox id="LanguagesDialogPane" class="prefpane largeDialogContainer">
 
     <stringbundleset id="languageSet">
       <stringbundle id="bundlePreferences"  src="chrome://browser/locale/preferences/preferences.properties"/>
       <stringbundle id="bundleAccepted"     src="resource://gre/res/language.properties"/>
     </stringbundleset>
 
-    <description>&languages.customize2.description;</description>
+    <description data-l10n-id="languages-description"/>
     <checkbox id="spoofEnglish"
-              label="&languages.customize.spoofEnglish;"
+              data-l10n-id="languages-customize-spoof-english"
               preference="privacy.spoof_english"
               onsyncfrompreference="return gLanguagesDialog.readSpoofEnglish();"
               onsynctopreference="return gLanguagesDialog.writeSpoofEnglish();"/>
     <grid flex="1">
       <columns>
         <column flex="1"/>
         <column/>
       </columns>
@@ -56,43 +52,38 @@
         <row flex="1">
           <listbox id="activeLanguages" flex="1" rows="6"
                     seltype="multiple" onselect="gLanguagesDialog.onLanguageSelect();"
                     preference="intl.accept_languages"
                     onsyncfrompreference="return gLanguagesDialog.readAcceptLanguages();"
                     onsynctopreference="return gLanguagesDialog.writeAcceptLanguages();"/>
           <vbox>
             <button id="up" class="up" oncommand="gLanguagesDialog.moveUp();" disabled="true"
-                    label="&languages.customize.moveUp.label;"
-                    accesskey="&languages.customize.moveUp.accesskey;"
+                    data-l10n-id="languages-customize-moveup"
                     preference="pref.browser.language.disable_button.up"/>
             <button id="down" class="down" oncommand="gLanguagesDialog.moveDown();" disabled="true"
-                    label="&languages.customize.moveDown.label;"
-                    accesskey="&languages.customize.moveDown.accesskey;"
+                    data-l10n-id="languages-customize-movedown"
                     preference="pref.browser.language.disable_button.down"/>
             <button id="remove" oncommand="gLanguagesDialog.removeLanguage();" disabled="true"
-                    label="&languages.customize.deleteButton.label;"
-                    accesskey="&languages.customize.deleteButton.accesskey;"
+                    data-l10n-id="languages-customize-remove"
                     preference="pref.browser.language.disable_button.remove"/>
           </vbox>
         </row>
         <row>
           <separator class="thin"/>
         </row>
         <row>
           <!-- This <vbox> is needed to position search tooltips correctly. -->
           <vbox>
             <menulist id="availableLanguages" oncommand="gLanguagesDialog.onAvailableLanguageSelect();"
-                      label="&languages.customize.selectLanguage.label;"
-                      label2="&languages.customize.selectLanguage.label;">
+                      data-l10n-id="languages-customize-select-language" data-l10n-attrs="placeholder">
               <menupopup id="availableLanguagesPopup"/>
             </menulist>
           </vbox>
           <button id="addButton" oncommand="gLanguagesDialog.addLanguage();" disabled="true"
-                  label="&languages.customize.addButton.label;"
-                  accesskey="&languages.customize.addButton.accesskey;"/>
+                  data-l10n-id="languages-customize-add"/>
         </row>
       </rows>
     </grid>
     <separator/>
     <separator/>
   </vbox>
 </dialog>
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/browser/preferences/languages.ftl
@@ -0,0 +1,34 @@
+# 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/.
+
+languages-window =
+    .title = Languages
+    .style = width: 30em
+
+languages-close-key =
+    .key = w
+
+languages-description = Web pages are sometimes offered in more than one language. Choose languages for displaying these web pages, in order of preference
+
+languages-customize-spoof-english =
+    .label = Request English versions of web pages for enhanced privacy
+
+languages-customize-moveup =
+    .label = Move Up
+    .accesskey = U
+
+languages-customize-movedown =
+    .label = Move Down
+    .accesskey = D
+
+languages-customize-remove =
+    .label = Remove
+    .accesskey = R
+
+languages-customize-select-language =
+    .placeholder = Select a language to add…
+
+languages-customize-add =
+    .label = Add
+    .accesskey = A
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/preferences/languages.dtd
+++ /dev/null
@@ -1,18 +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 window.width                                   "30em">
-
-<!ENTITY languages.customize.Header                     "Languages">
-<!ENTITY languages.customize2.description               "Web pages are sometimes offered in more than one language. Choose languages for displaying these web pages, in order of preference">
-<!ENTITY languages.customize.moveUp.label               "Move Up">
-<!ENTITY languages.customize.moveUp.accesskey           "U">
-<!ENTITY languages.customize.moveDown.label             "Move Down">
-<!ENTITY languages.customize.moveDown.accesskey         "D">
-<!ENTITY languages.customize.deleteButton.label         "Remove">
-<!ENTITY languages.customize.deleteButton.accesskey     "R">
-<!ENTITY languages.customize.selectLanguage.label       "Select a language to add…">
-<!ENTITY languages.customize.addButton.label            "Add">
-<!ENTITY languages.customize.addButton.accesskey        "A">
-<!ENTITY languages.customize.spoofEnglish               "Request English versions of web pages for enhanced privacy">
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -52,17 +52,16 @@
     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/content.dtd            (%chrome/browser/preferences/content.dtd)
-    locale/browser/preferences/languages.dtd          (%chrome/browser/preferences/languages.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)
     locale/browser/preferences/security.dtd           (%chrome/browser/preferences/security.dtd)
     locale/browser/preferences/selectBookmark.dtd     (%chrome/browser/preferences/selectBookmark.dtd)
     locale/browser/preferences/siteDataSettings.dtd     (%chrome/browser/preferences/siteDataSettings.dtd)
     locale/browser/preferences/sync.dtd               (%chrome/browser/preferences/sync.dtd)
     locale/browser/preferences/translation.dtd        (%chrome/browser/preferences/translation.dtd)
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1451992_preferences_languages.py
@@ -0,0 +1,160 @@
+# 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::Languages to Fluent, part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/preferences/languages.ftl',
+        'browser/browser/preferences/languages.ftl',
+        [
+            FTL.Message(
+                id=FTL.Identifier('languages-window'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('title'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.Header'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('style'),
+                        CONCAT(
+                            FTL.TextElement('width: '),
+                            COPY(
+                                'browser/chrome/browser/preferences/languages.dtd',
+                                'window.width'
+                            )
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-close-key'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('key'),
+                        COPY(
+                            'toolkit/chrome/global/preferences.dtd',
+                            'windowClose.key'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-description'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/languages.dtd',
+                    'languages.customize2.description'
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-customize-spoof-english'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.spoofEnglish'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-customize-moveup'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.moveUp.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.moveUp.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-customize-movedown'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.moveDown.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.moveDown.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-customize-remove'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.deleteButton.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.deleteButton.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-customize-select-language'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('placeholder'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.selectLanguage.label'
+                        )
+                    ),
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('languages-customize-add'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.addButton.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/languages.dtd',
+                            'languages.customize.addButton.accesskey'
+                        )
+                    )
+                ]
+            )
+        ]
+    )