Bug 1451992 - Migrate Preferences::Subdialogs::Blocklists to Fluent. r?gijs,pike draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Tue, 03 Apr 2018 04:29:25 +0200
changeset 779874 b3be5835f5caabf36f9d43fc31a82a1826e418dd
parent 779873 86fcae9ae0623a00e235d8918107c5729a67ec0c
child 779875 61c3855a3d2db754e99201013a5b623e787eda8f
push id105900
push userbmo:gandalf@aviary.pl
push dateTue, 10 Apr 2018 19:01:04 +0000
reviewersgijs, pike
bugs1451992
milestone61.0a1
Bug 1451992 - Migrate Preferences::Subdialogs::Blocklists to Fluent. r?gijs,pike MozReview-Commit-ID: IXacqfUnZ2q
browser/components/preferences/blocklists.js
browser/components/preferences/blocklists.xul
browser/components/preferences/in-content/preferences.xul
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/privacy.xul
browser/locales/en-US/browser/preferences/blocklists.ftl
browser/locales/en-US/chrome/browser/preferences/blocklists.dtd
browser/locales/en-US/chrome/browser/preferences/preferences.properties
browser/locales/jar.mn
python/l10n/fluent_migrations/bug_1451992_preferences_blocklists.py
--- a/browser/components/preferences/blocklists.js
+++ b/browser/components/preferences/blocklists.js
@@ -7,17 +7,16 @@ const BASE_LIST_ID = "base";
 const CONTENT_LIST_ID = "content";
 const TRACK_SUFFIX = "-track-digest256";
 const TRACKING_TABLE_PREF = "urlclassifier.trackingTable";
 const LISTS_PREF_BRANCH = "browser.safebrowsing.provider.mozilla.lists.";
 
 var gBlocklistManager = {
   _type: "",
   _blockLists: [],
-  _brandShortName: null,
   _bundle: null,
   _tree: null,
 
   _view: {
     _rowCount: 0,
     get rowCount() {
       return this._rowCount;
     },
@@ -70,25 +69,16 @@ var gBlocklistManager = {
 
   init(params) {
     if (this._type) {
       // reusing an open dialog, clear the old observer
       this.uninit();
     }
 
     this._type = "tracking";
-    this._brandShortName = params.brandShortName;
-
-    let blocklistsText = document.getElementById("blocklistsText");
-    while (blocklistsText.hasChildNodes()) {
-      blocklistsText.firstChild.remove();
-    }
-    blocklistsText.appendChild(document.createTextNode(params.introText));
-
-    document.title = params.windowTitle;
 
     this._loadBlockLists();
   },
 
   uninit() {},
 
   onListSelected() {
     for (let list of this._blockLists) {
--- a/browser/components/preferences/blocklists.xul
+++ b/browser/components/preferences/blocklists.xul
@@ -2,55 +2,57 @@
 
 <!-- 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" type="text/css"?>
 
-<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/blocklists.dtd" >
-
 <window id="BlocklistsDialog" class="windowDialog"
         windowtype="Browser:Blocklists"
-        title="&window.title;"
+        data-l10n-id="blocklist-window"
+        data-l10n-attrs="title, style"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        style="width: &window.width;;"
         onload="gBlocklistManager.onLoad();"
         onunload="gBlocklistManager.uninit();"
         persist="screenX screenY width height"
         onkeypress="gBlocklistManager.onWindowKeyPress(event);">
 
+  <link rel="localization" href="branding/brand.ftl"/>
+  <link rel="localization" href="browser/preferences/blocklists.ftl"/>
+  <script type="application/javascript" src="chrome://global/content/l10n.js"></script>
+
   <script src="chrome://global/content/treeUtils.js"/>
   <script src="chrome://browser/content/preferences/blocklists.js"/>
 
   <stringbundle id="bundlePreferences"
                 src="chrome://browser/locale/preferences/preferences.properties"/>
 
   <keyset>
-    <key key="&windowClose.key;" modifiers="accel" oncommand="window.close();"/>
+    <key data-l10n-id="blocklist-close-key" modifiers="accel" oncommand="window.close();"/>
   </keyset>
 
   <vbox class="contentPane largeDialogContainer" flex="1">
-    <description id="blocklistsText" control="url"/>
+    <description id="blocklistsText" data-l10n-id="blocklist-desc" control="url"/>
     <separator class="thin"/>
     <tree id="blocklistsTree" flex="1" style="height: 18em;"
           hidecolumnpicker="true"
           onselect="gBlocklistManager.onListSelected();">
       <treecols>
         <treecol id="selectionCol" label="" flex="1" sortable="false"
                  type="checkbox"/>
-        <treecol id="listCol" label="&treehead.list.label;" flex="80"
+        <treecol id="listCol" data-l10n-id="blocklist-treehead-list" flex="80"
                  sortable="false"/>
       </treecols>
       <treechildren/>
     </tree>
   </vbox>
   <vbox>
     <spacer flex="1"/>
     <hbox class="actionButtons" align="right" flex="1">
       <button oncommand="close();" icon="close"
-              label="&button.cancel.label;" accesskey="&button.cancel.accesskey;" />
+              data-l10n-id="blocklist-button-cancel"/>
       <button id="btnApplyChanges" oncommand="gBlocklistManager.onApplyChanges();" icon="save"
-              label="&button.ok.label;" accesskey="&button.ok.accesskey;"/>
+              data-l10n-id="blocklist-button-ok"/>
     </hbox>
   </vbox>
 </window>
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -72,16 +72,18 @@
       xmlns:html="http://www.w3.org/1999/xhtml"
       disablefastfind="true"
       data-l10n-id="pref-page"
       data-l10n-attrs="title">
 
   <link rel="localization" href="branding/brand.ftl"/>
   <link rel="localization" href="browser/branding/sync-brand.ftl"/>
   <link rel="localization" href="browser/preferences/preferences.ftl"/>
+  <link rel="localization" href="browser/preferences/blocklists.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"/>
   <script type="application/javascript"
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -399,20 +399,16 @@ var gPrivacyPane = {
     ]);
     appendSearchKeywords("cookieExceptions", [
       bundlePrefs.getString("cookiepermissionstext1"),
     ]);
     appendSearchKeywords("trackingProtectionExceptions", [
       bundlePrefs.getString("trackingprotectionpermissionstitle"),
       bundlePrefs.getString("trackingprotectionpermissionstext2"),
     ]);
-    appendSearchKeywords("changeBlockList", [
-      bundlePrefs.getString("blockliststitle"),
-      bundlePrefs.getString("blockliststext"),
-    ]);
     appendSearchKeywords("popupPolicyButton", [
       bundlePrefs.getString("popuppermissionstitle2"),
       bundlePrefs.getString("popuppermissionstext"),
     ]);
     appendSearchKeywords("notificationSettingsButton", [
       bundlePrefs.getString("notificationspermissionstitle2"),
       bundlePrefs.getString("notificationspermissionstext6"),
       bundlePrefs.getString("notificationspermissionsdisablelabel"),
@@ -786,26 +782,17 @@ var gPrivacyPane = {
     gSubDialog.open("chrome://browser/content/preferences/permissions.xul",
       null, params);
   },
 
   /**
    * Displays the available block lists for tracking protection.
    */
   showBlockLists() {
-    var bundlePreferences = document.getElementById("bundlePreferences");
-    let brandName = document.getElementById("bundleBrand")
-      .getString("brandShortName");
-    var params = {
-      brandShortName: brandName,
-      windowTitle: bundlePreferences.getString("blockliststitle"),
-      introText: bundlePreferences.getString("blockliststext")
-    };
-    gSubDialog.open("chrome://browser/content/preferences/blocklists.xul",
-      null, params);
+    gSubDialog.open("chrome://browser/content/preferences/blocklists.xul", null);
   },
 
   // COOKIES AND SITE DATA
 
   /*
    * Preferences:
    *
    * network.cookie.cookieBehavior
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -342,17 +342,17 @@
         </hbox>
         <!-- 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="changeBlockList"
                   class="accessory-button"
                   flex="1"
                   data-l10n-id="tracking-change-block-list"
                   preference="pref.privacy.disable_button.change_blocklist"
-                  searchkeywords="&button.cancel.label; &button.ok.label;"/>
+                  search-l10n-ids="blocklist-window.title, blocklist-desc, blocklist-button-cancel.label, blocklist-button-ok.label"/>
         </hbox>
       </vbox>
     </hbox>
     <vbox id="doNotTrackLearnMoreBox">
       <label><label class="tail-with-learn-more" data-l10n-id="do-not-track-description"></label><label
       class="learnMore text-link" href="https://www.mozilla.org/dnt"
       data-l10n-id="do-not-track-learn-more"></label></label>
       <radiogroup id="doNotTrackRadioGroup" aria-labelledby="doNotTrackDesc" preference="privacy.donottrackheader.enabled">
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/browser/preferences/blocklists.ftl
@@ -0,0 +1,22 @@
+# 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/.
+
+blocklist-window =
+    .title = Block Lists
+    .style = width: 55em
+
+blocklist-desc = You can choose which list { -brand-short-name } will use to block Web elements that may track your browsing activity.
+blocklist-close-key =
+    .key = w
+
+blocklist-treehead-list =
+    .label = List
+
+blocklist-button-cancel =
+    .label = Cancel
+    .accesskey = C
+
+blocklist-button-ok =
+    .label = Save Changes
+    .accesskey = S
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/preferences/blocklists.dtd
+++ /dev/null
@@ -1,14 +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.title                 "Block Lists">
-<!ENTITY window.width                 "55em">
-
-<!ENTITY treehead.list.label          "List">
-<!ENTITY windowClose.key              "w">
-
-<!ENTITY button.cancel.label          "Cancel">
-<!ENTITY button.cancel.accesskey      "C">
-<!ENTITY button.ok.label              "Save Changes">
-<!ENTITY button.ok.accesskey          "S">
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -46,18 +46,16 @@ microphonepermissionsdisablelabel=Block 
 microphonepermissionsdisabledescription=This will prevent any websites not listed above from requesting permission to access your microphone. Blocking access to your microphone may break some website features.
 invalidURI=Please enter a valid hostname
 invalidURITitle=Invalid Hostname Entered
 savedLoginsExceptions_title=Exceptions - Saved Logins
 savedLoginsExceptions_desc3=Logins for the following websites will not be saved
 
 #### Block List Manager
 
-blockliststext=You can choose which list Firefox will use to block Web elements that may track your browsing activity.
-blockliststitle=Block Lists
 # LOCALIZATION NOTE (mozNameTemplate): This template constructs the name of the
 # block list in the block lists dialog. It combines the list name and
 # description.
 #   e.g. mozNameTemplate : "Standard (Recommended). This list does a pretty good job."
 #   %1$S = list name (fooName), %2$S = list descriptive text (fooDesc)
 mozNameTemplate=%1$S %2$S
 # LOCALIZATION NOTE (mozstdName, etc.): These labels appear in the tracking
 # protection block lists dialog, mozNameTemplate is used to create the final
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -50,17 +50,16 @@
     locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)
     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/blocklists.dtd         (%chrome/browser/preferences/blocklists.dtd)
     locale/browser/preferences/clearSiteData.dtd      (%chrome/browser/preferences/clearSiteData.dtd)
     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)
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1451992_preferences_blocklists.py
@@ -0,0 +1,113 @@
+# 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::Blocklists to Fluent, part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/preferences/blocklists.ftl',
+        'browser/browser/preferences/blocklists.ftl',
+        [
+            FTL.Message(
+                id=FTL.Identifier('blocklist-window'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('title'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'window.title',
+                        ),
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('style'),
+                        CONCAT(
+                            FTL.TextElement('width: '),
+                            COPY(
+                                'browser/chrome/browser/preferences/blocklists.dtd',
+                                'window.width'
+                            )
+                        )
+                    ),
+                ],
+            ),
+            FTL.Message(
+                id=FTL.Identifier('blocklist-desc'),
+                value=REPLACE(
+                    'browser/chrome/browser/preferences/preferences.properties',
+                    'blockliststext',
+                    {
+                        'Firefox': MESSAGE_REFERENCE('-brand-short-name')
+                    },
+                ),
+            ),
+            FTL.Message(
+                id=FTL.Identifier('blocklist-close-key'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('key'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'windowClose.key',
+                        ),
+                    ),
+                ],
+            ),
+            FTL.Message(
+                id=FTL.Identifier('blocklist-treehead-list'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'treehead.list.label',
+                        ),
+                    ),
+                ],
+            ),
+            FTL.Message(
+                id=FTL.Identifier('blocklist-button-cancel'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'button.cancel.label',
+                        ),
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'button.cancel.accesskey',
+                        ),
+                    ),
+                ],
+            ),
+            FTL.Message(
+                id=FTL.Identifier('blocklist-button-ok'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'button.ok.label',
+                        ),
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/blocklists.dtd',
+                            'button.ok.accesskey',
+                        ),
+                    ),
+                ],
+            ),
+        ]
+    )