diff --git a/browser/components/extensions/schemas/commands.json b/browser/components/extensions/schemas/commands.json index 6f6d7eace2db..f85c841301d1 100644 --- a/browser/components/extensions/schemas/commands.json +++ b/browser/components/extensions/schemas/commands.json @@ -62,6 +62,7 @@ }, "description": { "type": "string", + "preprocess": "localize", "optional": true } } diff --git a/browser/components/extensions/test/browser/browser_ext_commands_getAll.js b/browser/components/extensions/test/browser/browser_ext_commands_getAll.js index 1360328df9fa..90f3a1cbbddc 100644 --- a/browser/components/extensions/test/browser/browser_ext_commands_getAll.js +++ b/browser/components/extensions/test/browser/browser_ext_commands_getAll.js @@ -4,8 +4,17 @@ 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": { @@ -26,6 +35,9 @@ add_task(async function() { "android": "Ctrl+Shift+A", }, }, + "with-translation": { + "description": "__MSG_with_translation__", + }, "without-suggested-key": { "description": "has no suggested_key", }, @@ -38,7 +50,7 @@ add_task(async 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"); @@ -69,6 +81,9 @@ add_task(async function() { 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");