Bug 1451992 - Migrate Preferences::Subdialogs::Translation to Fluent. r?gijs,stas draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 05 Apr 2018 22:55:44 +0200
changeset 780757 0bda695ed4272ac6856cb8762a565f0aca65307e
parent 780756 2eba87264c58377751f7f72d4c45046de38b53fd
push id106121
push userbmo:gandalf@aviary.pl
push dateThu, 12 Apr 2018 00:27:59 +0000
reviewersgijs, stas
bugs1451992
milestone61.0a1
Bug 1451992 - Migrate Preferences::Subdialogs::Translation to Fluent. r?gijs,stas MozReview-Commit-ID: JfBdle6i5wL
browser/components/preferences/translation.xul
browser/locales/en-US/browser/preferences/translation.ftl
browser/locales/en-US/chrome/browser/preferences/translation.dtd
browser/locales/jar.mn
python/l10n/fluent_migrations/bug_1451992_preferences_translation.py
--- a/browser/components/preferences/translation.xul
+++ b/browser/components/preferences/translation.xul
@@ -2,87 +2,92 @@
 
 <!-- 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/translation.dtd">
-
 <window id="TranslationDialog" class="windowDialog"
         windowtype="Browser:TranslationExceptions"
-        title="&window.title;"
+        data-l10n-id="translation-window"
+        data-l10n-attrs="title, style"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        style="width: &window.width;;"
         onload="gTranslationExceptions.onLoad();"
         onunload="gTranslationExceptions.uninit();"
         persist="screenX screenY width height"
         onkeypress="gTranslationExceptions.onWindowKeyPress(event);">
 
+  <link rel="localization" href="browser/preferences/translation.ftl"/>
+  <script type="application/javascript" src="chrome://global/content/l10n.js"></script>
+
   <script src="chrome://browser/content/preferences/translation.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="translation-close-key" modifiers="accel" oncommand="window.close();"/>
   </keyset>
 
   <vbox class="largeDialogContainer">
     <vbox class="contentPane" flex="1">
-      <label id="languagesLabel" control="permissionsTree">&noTranslationForLanguages2.label;</label>
+      <label id="languagesLabel"
+             data-l10n-id="translation-languages-disabled-desc"
+             control="permissionsTree"/>
       <separator class="thin"/>
       <tree id="languagesTree" flex="1" style="height: 12em;"
             hidecolumnpicker="true"
             onkeypress="gTranslationExceptions.onLanguageKeyPress(event)"
             onselect="gTranslationExceptions.onLanguageSelected();">
         <treecols>
-          <treecol id="languageCol" label="&treehead.languageName.label;" flex="1"/>
+          <treecol id="languageCol" data-l10n-id="translation-languages-column" flex="1"/>
         </treecols>
         <treechildren/>
       </tree>
     </vbox>
     <hbox align="end">
       <hbox class="actionButtons" flex="1">
         <button id="removeLanguage" disabled="true"
-                accesskey="&removeLanguage.accesskey;"
-                icon="remove" label="&removeLanguage.label;"
+                data-l10n-id="translation-languages-button-remove"
+                icon="remove"
                 oncommand="gTranslationExceptions.onLanguageDeleted();"/>
         <button id="removeAllLanguages"
-                icon="clear" label="&removeAllLanguages.label;"
-                accesskey="&removeAllLanguages.accesskey;"
+                data-l10n-id="translation-languages-button-remove-all"
+                icon="clear"
                 oncommand="gTranslationExceptions.onAllLanguagesDeleted();"/>
         <spacer flex="1"/>
       </hbox>
     </hbox>
     <separator/>
     <vbox class="contentPane" flex="1">
-      <label id="languagesLabel" control="permissionsTree">&noTranslationForSites2.label;</label>
+      <label id="languagesLabel"
+             data-l10n-id="translation-sites-disabled-desc"
+             control="permissionsTree"/>
       <separator class="thin"/>
       <tree id="sitesTree" flex="1" style="height: 12em;"
             hidecolumnpicker="true"
             onkeypress="gTranslationExceptions.onSiteKeyPress(event)"
             onselect="gTranslationExceptions.onSiteSelected();">
         <treecols>
-          <treecol id="siteCol" label="&treehead.siteName2.label;" flex="1"/>
+          <treecol id="siteCol" data-l10n-id="translation-sites-column" flex="1"/>
         </treecols>
         <treechildren/>
       </tree>
     </vbox>
   </vbox>
   <hbox align="end">
     <hbox class="actionButtons" flex="1">
       <button id="removeSite" disabled="true"
-              accesskey="&removeSite.accesskey;"
-              icon="remove" label="&removeSite.label;"
+              data-l10n-id="translation-sites-button-remove"
+              icon="remove"
               oncommand="gTranslationExceptions.onSiteDeleted();"/>
       <button id="removeAllSites"
-              icon="clear" label="&removeAllSites.label;"
-              accesskey="&removeAllSites.accesskey;"
+              data-l10n-id="translation-sites-button-remove-all"
+              icon="clear"
               oncommand="gTranslationExceptions.onAllSitesDeleted();"/>
       <spacer flex="1"/>
       <button oncommand="close();" icon="close"
-              label="&button.close.label;" accesskey="&button.close.accesskey;"/>
+              data-l10n-id="translation-button-close"/>
     </hbox>
   </hbox>
 </window>
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/browser/preferences/translation.ftl
@@ -0,0 +1,40 @@
+# 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/.
+
+translation-window =
+    .title = Exceptions - Translation
+    .style = width: 36em
+
+translation-close-key =
+    .key = w
+
+translation-languages-disabled-desc = Translation will not be offered for the following languages
+
+translation-languages-column =
+    .label = Languages
+
+translation-languages-button-remove =
+    .label = Remove Language
+    .accesskey = R
+
+translation-languages-button-remove-all =
+    .label = Remove All Languages
+    .accesskey = e
+
+translation-sites-disabled-desc = Translation will not be offered for the following sites
+
+translation-sites-column =
+    .label = Websites
+
+translation-sites-button-remove =
+    .label = Remove Site
+    .accesskey = S
+
+translation-sites-button-remove-all =
+    .label = Remove All Sites
+    .accesskey = i
+
+translation-button-close =
+    .label = Close
+    .accesskey = C
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/preferences/translation.dtd
+++ /dev/null
@@ -1,24 +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                     "Exceptions - Translation">
-<!ENTITY window.width                     "36em">
-<!ENTITY windowClose.key                  "w">
-
-<!ENTITY noTranslationForLanguages2.label "Translation will not be offered for the following languages">
-<!ENTITY treehead.languageName.label      "Languages">
-<!ENTITY removeLanguage.label             "Remove Language">
-<!ENTITY removeLanguage.accesskey         "R">
-<!ENTITY removeAllLanguages.label         "Remove All Languages">
-<!ENTITY removeAllLanguages.accesskey     "e">
-
-<!ENTITY noTranslationForSites2.label     "Translation will not be offered for the following sites">
-<!ENTITY treehead.siteName2.label         "Websites">
-<!ENTITY removeSite.label                 "Remove Site">
-<!ENTITY removeSite.accesskey             "S">
-<!ENTITY removeAllSites.label             "Remove All Sites">
-<!ENTITY removeAllSites.accesskey         "i">
-
-<!ENTITY button.close.label               "Close">
-<!ENTITY button.close.accesskey           "C">
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -56,17 +56,16 @@
     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/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/sync.dtd               (%chrome/browser/preferences/sync.dtd)
-    locale/browser/preferences/translation.dtd        (%chrome/browser/preferences/translation.dtd)
     locale/browser/syncBrand.dtd                (%chrome/browser/syncBrand.dtd)
     locale/browser/syncSetup.properties         (%chrome/browser/syncSetup.properties)
 #if BUILD_FASTER
     locale/browser/searchplugins/               (searchplugins/*.xml)
     locale/browser/searchplugins/list.json      (search/list.json)
 #else
     locale/browser/searchplugins/               (.deps/generated_@AB_CD@/*.xml)
     locale/browser/searchplugins/list.json      (.deps/generated_@AB_CD@/list.json)
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1451992_preferences_translation.py
@@ -0,0 +1,186 @@
+# 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::Translation to Fluent, part {index}."""
+
+    ctx.add_transforms(
+        'browser/browser/preferences/translation.ftl',
+        'browser/browser/preferences/translation.ftl',
+        [
+            FTL.Message(
+                id=FTL.Identifier('translation-window'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('title'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'window.title'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('style'),
+                        CONCAT(
+                            FTL.TextElement('width: '),
+                            COPY(
+                                'browser/chrome/browser/preferences/translation.dtd',
+                                'window.width'
+                            )
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-close-key'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('key'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'windowClose.key'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-languages-disabled-desc'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/translation.dtd',
+                    'noTranslationForLanguages2.label'
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-languages-column'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'treehead.languageName.label'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-languages-button-remove'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeLanguage.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeLanguage.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-languages-button-remove-all'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeAllLanguages.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeAllLanguages.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-sites-disabled-desc'),
+                value=COPY(
+                    'browser/chrome/browser/preferences/translation.dtd',
+                    'noTranslationForSites2.label'
+                )
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-sites-column'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'treehead.siteName2.label'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-sites-button-remove'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeSite.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeSite.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-sites-button-remove-all'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeAllSites.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'removeAllSites.accesskey'
+                        )
+                    )
+                ]
+            ),
+            FTL.Message(
+                id=FTL.Identifier('translation-button-close'),
+                attributes=[
+                    FTL.Attribute(
+                        FTL.Identifier('label'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'button.close.label'
+                        )
+                    ),
+                    FTL.Attribute(
+                        FTL.Identifier('accesskey'),
+                        COPY(
+                            'browser/chrome/browser/preferences/translation.dtd',
+                            'button.close.accesskey'
+                        )
+                    )
+                ]
+            )
+        ]
+    )