diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 4c47d2fc972..1a6e737a23a 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -36,6 +36,44 @@ const BUTTON_POSITION_SAVE = 0; const BUTTON_POSITION_CANCEL = 1; const BUTTON_POSITION_DONT_SAVE = 2; +let keysbundle = Services.strings.createBundle("chrome://global-platform/locale/platformKeys.properties"); + + +function SP_Pretty_Key(aElemKey) { + + let elemString = ""; + let elemMod = aElemKey.getAttribute("modifiers"); + + if (elemMod.match("accel")) { + if (navigator.platform.indexOf("Mac") !== -1) { + elemString += keysbundle.GetStringFromName("VK_META") + + keysbundle.GetStringFromName("MODIFIER_SEPARATOR"); + } else { + elemString += keysbundle.GetStringFromName("VK_CONTROL") + + keysbundle.GetStringFromName("MODIFIER_SEPARATOR"); + } + } + + if (elemMod.match("shift")) { + elemString += keysbundle.GetStringFromName("VK_SHIFT") + + keysbundle.GetStringFromName("MODIFIER_SEPARATOR"); + } + if (elemMod.match("alt")) { + elemString += keysbundle.GetStringFromName("VK_ALT") + + keysbundle.GetStringFromName("MODIFIER_SEPARATOR"); + } + if (elemMod.match("ctrl")) { + elemString += keysbundle.GetStringFromName("VK_CONTROL") + + keysbundle.GetStringFromName("MODIFIER_SEPARATOR"); + } + if (elemMod.match("meta")) { + elemString += keysbundle.GetStringFromName("VK_META") + + keysbundle.GetStringFromName("MODIFIER_SEPARATOR"); + } + + return elemString + aElemKey.getAttribute("key").toUpperCase(); +} + /** * The scratchpad object handles the Scratchpad window functionality. */ @@ -971,7 +1009,14 @@ var Scratchpad = { } let state = null; - let initialText = this.strings.GetStringFromName("scratchpadIntro"); + + let initialText = this.strings.formatStringFromName( + "scratchpadIntro1", + [SP_Pretty_Key(document.getElementById("sp-key-run")), + SP_Pretty_Key(document.getElementById("sp-key-inspect")), + SP_Pretty_Key(document.getElementById("sp-key-display"))], + 3); + if ("arguments" in window && window.arguments[0] instanceof Ci.nsIDialogParamBlock) { state = JSON.parse(window.arguments[0].GetString(0)); diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_open.js b/browser/devtools/scratchpad/test/browser_scratchpad_open.js index 5af2ffaf2c5..c2a63f4030f 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_open.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_open.js @@ -25,9 +25,7 @@ function testOpen() { openScratchpad(function(win) { is(win.Scratchpad.filename, undefined, "Default filename is undefined"); - is(win.Scratchpad.getText(), - win.Scratchpad.strings.GetStringFromName("scratchpadIntro"), - "Default text is loaded") + isnot(win.Scratchpad.getText(), null, "Default text should not be null"); is(win.Scratchpad.executionContext, win.SCRATCHPAD_CONTEXT_CONTENT, "Default execution context is content"); diff --git a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties index 5fea1b4263d..0fcd2c8f302 100644 --- a/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties +++ b/browser/locales/en-US/chrome/browser/devtools/scratchpad.properties @@ -57,7 +57,7 @@ confirmClose.title=Unsaved Changes # LOCALIZATION NOTE (scratchpadIntro): This is a multi-line comment explaining # how to use the Scratchpad. Note that this should be a valid JavaScript # comment inside /* and */. -scratchpadIntro=/*\n * This is a JavaScript Scratchpad.\n *\n * Enter some JavaScript, then Right Click or choose from the Execute Menu:\n * 1. Run to evaluate the selected text,\n * 2. Inspect to bring up an Object Inspector on the result, or,\n * 3. Display to insert the result in a comment after the selection.\n */\n\n +scratchpadIntro1=/*\n * This is a JavaScript Scratchpad.\n *\n * Enter some JavaScript, then Right Click or choose from the Execute Menu:\n * 1. Run to evaluate the selected text (%1$S),\n * 2. Inspect to bring up an Object Inspector on the result (%2$S), or,\n * 3. Display to insert the result in a comment after the selection. (%3$S)\n */\n\n # LOCALIZATION NOTE (notification.browserContext): This is the message displayed # over the top of the editor when the user has switched to browser context.