Bug 1303384 - Part 4: Localize command descriptions r=aswan
authorMark Striemer <mstriemer@mozilla.com>
Sat, 12 Jan 2019 02:25:23 +0000
changeset 510838 77c0cf8378dfcf66180f474caa49208e973e9d88
parent 510837 456b9b7963eb9c0815f8fa250de5424317c00001
child 510839 c30316708edcc4da5e3aebf211dc5e1662cfae48
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1303384
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1303384 - Part 4: Localize command descriptions r=aswan Differential Revision: https://phabricator.services.mozilla.com/D6346
browser/components/extensions/schemas/commands.json
browser/components/extensions/test/browser/browser_ext_commands_getAll.js
--- a/browser/components/extensions/schemas/commands.json
+++ b/browser/components/extensions/schemas/commands.json
@@ -57,16 +57,17 @@
                       "type": "string",
                       "deprecated": "Unknown platform name",
                       "optional": true
                     }
                   }
                 },
                 "description": {
                   "type": "string",
+                  "preprocess": "localize",
                   "optional": true
                 }
               }
             }
           }
         }
       }
     ]
--- a/browser/components/extensions/test/browser/browser_ext_commands_getAll.js
+++ b/browser/components/extensions/test/browser/browser_ext_commands_getAll.js
@@ -1,16 +1,25 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(async function() {
   let extension = ExtensionTestUtils.loadExtension({
+    files: {
+      "_locales/en/messages.json": {
+        "with_translation": {
+          "message": "The description",
+          "description": "A description",
+        },
+      },
+    },
     manifest: {
       "name": "Commands Extension",
+      "default_locale": "en",
       "commands": {
         "with-desciption": {
           "suggested_key": {
             "default": "Ctrl+Shift+Y",
           },
           "description": "should have a description",
         },
         "without-description": {
@@ -21,29 +30,32 @@ add_task(async function() {
         "with-platform-info": {
           "suggested_key": {
             "mac": "Ctrl+Shift+M",
             "linux": "Ctrl+Shift+L",
             "windows": "Ctrl+Shift+W",
             "android": "Ctrl+Shift+A",
           },
         },
+        "with-translation": {
+          "description": "__MSG_with_translation__",
+        },
         "without-suggested-key": {
           "description": "has no suggested_key",
         },
         "without-suggested-key-nor-description": {
         },
       },
     },
 
     background: function() {
       browser.test.onMessage.addListener((message, additionalScope) => {
         browser.commands.getAll((commands) => {
           let errorMessage = "getAll should return an array of commands";
-          browser.test.assertEq(commands.length, 5, errorMessage);
+          browser.test.assertEq(commands.length, 6, errorMessage);
 
           let command = commands.find(c => c.name == "with-desciption");
 
           errorMessage = "The description should match what is provided in the manifest";
           browser.test.assertEq("should have a description", command.description, errorMessage);
 
           errorMessage = "The shortcut should match the default shortcut provided in the manifest";
           browser.test.assertEq("Ctrl+Shift+Y", command.shortcut, errorMessage);
@@ -64,16 +76,19 @@ add_task(async function() {
           };
 
           command = commands.find(c => c.name == "with-platform-info");
           let platformKey = platformKeys[additionalScope.platform];
           let shortcut = `Ctrl+Shift+${platformKey}`;
           errorMessage = `The shortcut should match the one provided in the manifest for OS='${additionalScope.platform}'`;
           browser.test.assertEq(shortcut, command.shortcut, errorMessage);
 
+          command = commands.find(c => c.name == "with-translation");
+          browser.test.assertEq(command.description, "The description", "The description can be localized");
+
           command = commands.find(c => c.name == "without-suggested-key");
 
           browser.test.assertEq("has no suggested_key", command.description, "The description should match what is provided in the manifest");
 
           browser.test.assertEq(null, command.shortcut, "The shortcut should be empty if not provided");
 
           command = commands.find(c => c.name == "without-suggested-key-nor-description");