Bug 1453480 - Migrate Fluent resources to use DOM Overlays v2. r?flod draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Wed, 11 Apr 2018 16:09:31 -0700
changeset 781747 b5e84af304bed1b33b2752a2e481a590ea607a81
parent 781746 cc16e8767bbbc4be05a45d12290fa547d1b8cfda
child 781748 8680348e0a2b7f1e5642fe1d6d51e504f8213ab6
push id106408
push userbmo:gandalf@aviary.pl
push dateFri, 13 Apr 2018 15:38:34 +0000
reviewersflod
bugs1453480
milestone61.0a1
Bug 1453480 - Migrate Fluent resources to use DOM Overlays v2. r?flod MozReview-Commit-ID: IsaYQFyPAxd
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/main.xul
browser/components/preferences/in-content/privacy.xul
browser/components/preferences/in-content/searchResults.xul
browser/locales/en-US/browser/preferences/preferences.ftl
python/l10n/fluent_migrations/bug_1453480_preferences_dom2_resources.py
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -453,17 +453,17 @@ var gMainPane = {
     let archResource = Services.appinfo.is64Bit
       ? "aboutDialog.architecture.sixtyFourBit"
       : "aboutDialog.architecture.thirtyTwoBit";
     let arch = bundle.GetStringFromName(archResource);
     version += ` (${arch})`;
 
     document.l10n.setAttributes(
       document.getElementById("updateAppInfo"),
-      "update-application-info",
+      "update-application-version",
       { version }
     );
 
     // Show a release notes link if we have a URL.
     let relNotesLink = document.getElementById("releasenotes");
     let relNotesPrefType = Services.prefs.getPrefType("app.releaseNotesURL");
     if (relNotesPrefType != Services.prefs.PREF_INVALID) {
       let relNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL");
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -437,17 +437,17 @@
 <!-- Update -->
 <groupbox id="updateApp" data-category="paneGeneral" hidden="true">
   <caption class="search-header" hidden="true"><label data-l10n-id="update-application-title"/></caption>
 
   <label data-l10n-id="update-application-description"/>
   <hbox align="center">
     <vbox flex="1">
       <description id="updateAppInfo">
-        <html:a id="releasenotes" class="learnMore text-link" hidden="true"/>
+        <html:a id="releasenotes" data-l10n-name="learn-more" class="learnMore text-link" hidden="true"/>
       </description>
       <description id="distribution" class="text-blurb" hidden="true"/>
       <description id="distributionId" class="text-blurb" hidden="true"/>
     </vbox>
 #ifdef MOZ_UPDATER
     <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. -->
     <vbox>
@@ -610,18 +610,18 @@
           <menuitem label="4" value="4"/>
           <menuitem label="5" value="5"/>
           <menuitem label="6" value="6"/>
           <menuitem label="7" value="7"/>
         </menupopup>
       </menulist>
     </hbox>
     <description id="contentProcessCountEnabledDescription" class="tip-caption" data-l10n-id="performance-limit-content-process-enabled-desc"/>
-    <description id="contentProcessCountDisabledDescription" class="tip-caption" data-l10n-id="performance-limit-content-process-disabled-desc">
-      <html:a class="text-link" href="https://wiki.mozilla.org/Electrolysis"/>
+    <description id="contentProcessCountDisabledDescription" class="tip-caption" data-l10n-id="performance-limit-content-process-blocked-desc">
+      <html:a class="text-link" data-l10n-name="learn-more" href="https://wiki.mozilla.org/Electrolysis"/>
     </description>
   </vbox>
 </groupbox>
 
 <hbox id="browsingCategory"
       class="subcategory"
       hidden="true"
       data-category="paneGeneral">
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -276,18 +276,18 @@
 </groupbox>
 
 <!-- Tracking -->
 <groupbox id="trackingGroup" data-category="panePrivacy" hidden="true">
   <caption><label data-l10n-id="tracking-header"/></caption>
   <vbox>
     <hbox align="start">
       <vbox flex="1">
-        <description data-l10n-id="tracking-description">
-          <a id="trackingProtectionLearnMore" target="_blank" class="learnMore text-link"/>
+        <description data-l10n-id="tracking-desc">
+          <a id="trackingProtectionLearnMore" data-l10n-name="learn-more" target="_blank" class="learnMore text-link"/>
         </description>
       </vbox>
       <spacer flex="1"/>
     </hbox>
     <hbox>
       <vbox id="trackingProtectionBox" flex="1" hidden="true">
         <vbox>
           <hbox id="trackingProtectionExtensionContentLabel" align="center" hidden="true">
--- a/browser/components/preferences/in-content/searchResults.xul
+++ b/browser/components/preferences/in-content/searchResults.xul
@@ -10,19 +10,19 @@
   <label class="header-name" flex="1" data-l10n-id="search-results-header" />
 </hbox>
 
 <groupbox id="no-results-message"
           data-hidden-from-search="true"
           data-category="paneSearchResults"
           hidden="true">
   <vbox class="no-results-container">
-    <label id="sorry-message" data-l10n-id="search-results-sorry-message">
-      <html:span id="sorry-message-query"/>
+    <label id="sorry-message" data-l10n-id="search-results-empty-message">
+      <html:span data-l10n-name="query" id="sorry-message-query"/>
     </label>
-    <label id="need-help" data-l10n-id="search-results-need-help">
-      <a class="text-link" target="_blank"></a>
+    <label id="need-help" data-l10n-id="search-results-help-link">
+      <a class="text-link" data-l10n-name="url" target="_blank"></a>
     </label>
   </vbox>
   <vbox class="no-results-container" align="center">
     <image></image>
   </vbox>
 </groupbox>
--- a/browser/locales/en-US/browser/preferences/preferences.ftl
+++ b/browser/locales/en-US/browser/preferences/preferences.ftl
@@ -75,24 +75,24 @@ should-restart-title = Restart { -brand-
 should-restart-ok = Restart { -brand-short-name } now
 cancel-no-restart-button = Cancel
 restart-later = Restart Later
 
 ## Preferences UI Search Results
 
 search-results-header = Search Results
 
-# `<span></span>` will be replaced by the search term.
-search-results-sorry-message =
+# `<span data-l10n-name="query"></span>` will be replaced by the search term.
+search-results-empty-message =
     { PLATFORM() ->
-        [windows] Sorry! There are no results in Options for “<span></span>”.
-       *[other] Sorry! There are no results in Preferences for “<span></span>”.
+        [windows] Sorry! There are no results in Options for “<span data-l10n-name="query"></span>”.
+       *[other] Sorry! There are no results in Preferences for “<span data-l10n-name="query"></span>”.
     }
 
-search-results-need-help = Need help? Visit <a>{ -brand-short-name } Support</a>
+search-results-help-link = Need help? Visit <a data-l10n-name="url">{ -brand-short-name } Support</a>
 
 ## General Section
 
 startup-header = Startup
 
 # { -brand-short-name } will be 'Firefox Developer Edition',
 # since this setting is only exposed in Firefox Developer Edition
 separate-profile-mode =
@@ -262,17 +262,17 @@ play-drm-content =
     .accesskey = P
 
 play-drm-content-learn-more = Learn more
 
 update-application-title = { -brand-short-name } Updates
 
 update-application-description = Keep { -brand-short-name } up to date for the best performance, stability, and security.
 
-update-application-info = Version { $version } <a>What's new</a>
+update-application-version = Version { $version } <a data-l10n-name="learn-more">What’s new</a>
 
 update-history =
     .label = Show Update History…
     .accesskey = p
 
 update-application-allow-description = Allow { -brand-short-name } to
 
 update-application-auto =
@@ -310,17 +310,17 @@ performance-settings-learn-more = Learn 
 performance-allow-hw-accel =
     .label = Use hardware acceleration when available
     .accesskey = r
 
 performance-limit-content-process-option = Content process limit
     .accesskey = l
 
 performance-limit-content-process-enabled-desc = Additional content processes can improve performance when using multiple tabs, but will also use more memory.
-performance-limit-content-process-disabled-desc = Modifying the number of content processes is only possible with multiprocess { -brand-short-name }. <a>Learn how to check if multiprocess is enabled</a>
+performance-limit-content-process-blocked-desc = Modifying the number of content processes is only possible with multiprocess { -brand-short-name }. <a data-l10n-name="learn-more">Learn how to check if multiprocess is enabled</a>
 
 # Variables:
 #   $num - default value of the `dom.ipc.processCount` pref.
 performance-default-content-process-count =
     .label = { $num } (default)
 
 ## General Section - Browsing
 
@@ -693,17 +693,17 @@ addressbar-locbar-openpage-option =
     .accesskey = O
 
 addressbar-suggestions-settings = Change preferences for search engine suggestions
 
 ## Privacy Section - Tracking
 
 tracking-header = Tracking Protection
 
-tracking-description = Tracking Protection blocks online trackers that collect your browsing data across multiple websites. <a>Learn more about Tracking Protection and your privacy</a>
+tracking-desc = Tracking Protection blocks online trackers that collect your browsing data across multiple websites. <a data-l10n-name="learn-more">Learn more about Tracking Protection and your privacy</a>
 
 tracking-mode-label = Use Tracking Protection to block known trackers
 
 tracking-mode-always =
     .label = Always
     .accesskey = y
 tracking-mode-private =
     .label = Only in private windows
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1453480_preferences_dom2_resources.py
@@ -0,0 +1,130 @@
+# 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, EXTERNAL_ARGUMENT
+from fluent.migrate import COPY, CONCAT, REPLACE
+
+def migrate(ctx):
+    """Bug 1453480 - Migrate Fluent resources to use DOM Overlays, part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/preferences/preferences.ftl',
+        'browser/browser/preferences/preferences.ftl',
+        [
+            FTL.Message(
+                id=FTL.Identifier('search-results-empty-message'),
+                value=FTL.Pattern(
+                    elements=[
+                        FTL.Placeable(
+                            expression=FTL.SelectExpression(
+                                expression=FTL.CallExpression(
+                                    callee=FTL.Function('PLATFORM')
+                                ),
+                                variants=[
+                                    FTL.Variant(
+                                        key=FTL.VariantName('windows'),
+                                        default=False,
+                                        value=REPLACE(
+                                            'browser/chrome/browser/preferences/preferences.properties',
+                                            'searchResults.sorryMessageWin',
+                                            {
+                                                '%S': FTL.TextElement('<span data-l10n-name="query"></span>')
+                                            }
+                                        )
+                                    ),
+                                    FTL.Variant(
+                                        key=FTL.VariantName('other'),
+                                        default=True,
+                                        value=REPLACE(
+                                            'browser/chrome/browser/preferences/preferences.properties',
+                                            'searchResults.sorryMessageUnix',
+                                            {
+                                                '%S': FTL.TextElement('<span data-l10n-name="query"></span>')
+                                            }
+                                        )
+                                    )
+                                ]
+                            )
+                        )
+                    ]
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('search-results-help-link'),
+                value=REPLACE(
+                    'browser/chrome/browser/preferences/preferences.properties',
+                    'searchResults.needHelp3',
+                    {
+                        '%S': CONCAT(
+                            FTL.TextElement('<a data-l10n-name="url">'),
+                            REPLACE(
+                                'browser/chrome/browser/preferences/preferences.properties',
+                                'searchResults.needHelpSupportLink',
+                                {
+                                    '%S': MESSAGE_REFERENCE('-brand-short-name'),
+                                }
+                            ),
+                            FTL.TextElement('</a>')
+                        )
+                    }
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('update-application-version'),
+                value=CONCAT(
+                    COPY(
+                        'browser/chrome/browser/preferences/advanced.dtd',
+                        'updateApplication.version.pre'
+                    ),
+                    EXTERNAL_ARGUMENT('version'),
+                    COPY(
+                        'browser/chrome/browser/preferences/advanced.dtd',
+                        'updateApplication.version.post'
+                    ),
+                    FTL.TextElement(' <a data-l10n-name="learn-more">'),
+                    COPY(
+                        'browser/chrome/browser/aboutDialog.dtd',
+                        'releaseNotes.link'
+                    ),
+                    FTL.TextElement('</a>')
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('performance-limit-content-process-blocked-desc'),
+                value=CONCAT(
+                    REPLACE(
+                        'browser/chrome/browser/preferences/advanced.dtd',
+                        'limitContentProcessOption.disabledDescription',
+                        {
+                            '&brandShortName;': MESSAGE_REFERENCE('-brand-short-name')
+                        }
+                    ),
+                    FTL.TextElement(' <a data-l10n-name="learn-more">'),
+                    COPY(
+                        'browser/chrome/browser/preferences/advanced.dtd',
+                        'limitContentProcessOption.disabledDescriptionLink'
+                    ),
+                    FTL.TextElement('</a>')
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('tracking-desc'),
+                value=CONCAT(
+                    COPY(
+                        'browser/chrome/browser/preferences/privacy.dtd',
+                        'trackingProtection3.description'
+                    ),
+                    FTL.TextElement(' <a data-l10n-name="learn-more">'),
+                    COPY(
+                        'browser/chrome/browser/preferences/privacy.dtd',
+                        'trackingProtectionLearnMore2.label'
+                    ),
+                    FTL.TextElement('</a>')
+                )
+            ),
+        ]
+    )