Bug 1295610 - Migrate devtools/client/framework to use l10n.js instead of Services.string;r=tromey

MozReview-Commit-ID: BwcfFPf85hu

--HG--
extra : rebase_source : 6408bd173b694bfa6df72fb8452a0cb406132f45
This commit is contained in:
Julian Descottes 2016-08-19 20:02:15 +02:00
Родитель a07c10bd7b
Коммит 80a3b3ed70
13 изменённых файлов: 76 добавлений и 118 удалений

Просмотреть файл

@ -8,14 +8,8 @@ const {Cc, Ci, Cu} = require("chrome");
const Services = require("Services"); const Services = require("Services");
const defer = require("devtools/shared/defer"); const defer = require("devtools/shared/defer");
function l10n(name) { const {LocalizationHelper} = require("devtools/shared/l10n");
const bundle = Services.strings.createBundle("chrome://devtools/locale/toolbox.properties"); const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
try {
return bundle.GetStringFromName(name);
} catch (e) {
throw new Error("Failed loading l10n string: " + name);
}
}
function handleThreadState(toolbox, event, packet) { function handleThreadState(toolbox, event, packet) {
// Suppress interrupted events by default because the thread is // Suppress interrupted events by default because the thread is
@ -78,7 +72,7 @@ function attachThread(toolbox) {
if (res.error === "wrongOrder") { if (res.error === "wrongOrder") {
const box = toolbox.getNotificationBox(); const box = toolbox.getNotificationBox();
box.appendNotification( box.appendNotification(
l10n("toolbox.resumeOrderWarning"), L10N.getStr("toolbox.resumeOrderWarning"),
"wrong-resume-order", "wrong-resume-order",
"", "",
box.PRIORITY_WARNING_HIGH box.PRIORITY_WARNING_HIGH

Просмотреть файл

@ -12,8 +12,8 @@
* - devtools/client/definitions for tool-specifics entries * - devtools/client/definitions for tool-specifics entries
*/ */
const Services = require("Services"); const {LocalizationHelper} = require("devtools/shared/l10n");
const MenuStrings = Services.strings.createBundle("chrome://devtools/locale/menus.properties"); const MENUS_L10N = new LocalizationHelper("devtools/locale/menus.properties");
loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true); loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true); loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
@ -23,7 +23,7 @@ loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/de
const FragmentsCache = new Map(); const FragmentsCache = new Map();
function l10n(key) { function l10n(key) {
return MenuStrings.GetStringFromName(key); return MENUS_L10N.getStr(key);
} }
/** /**

Просмотреть файл

@ -8,21 +8,18 @@
var Cu = Components.utils; var Cu = Components.utils;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
var Services = require("Services"); var Services = require("Services");
var {gDevTools} = require("devtools/client/framework/devtools"); var {gDevTools} = require("devtools/client/framework/devtools");
var {TargetFactory} = require("devtools/client/framework/target"); var {TargetFactory} = require("devtools/client/framework/target");
var {Toolbox} = require("devtools/client/framework/toolbox"); var {Toolbox} = require("devtools/client/framework/toolbox");
var {DebuggerClient} = require("devtools/shared/client/main"); var {DebuggerClient} = require("devtools/shared/client/main");
var {Task} = require("devtools/shared/task"); var {Task} = require("devtools/shared/task");
var {LocalizationHelper} = require("devtools/shared/l10n");
var L10N = new LocalizationHelper("devtools/locale/connection-screen.properties");
var gClient; var gClient;
var gConnectionTimeout; var gConnectionTimeout;
XPCOMUtils.defineLazyGetter(window, "l10n", function () {
return Services.strings.createBundle("chrome://devtools/locale/connection-screen.properties");
});
/** /**
* Once DOM is ready, we prefil the host/port inputs with * Once DOM is ready, we prefil the host/port inputs with
* pref-stored values. * pref-stored values.
@ -134,7 +131,7 @@ var onConnectionReady = Task.async(function* ([aType, aTraits]) {
openToolbox(globals, true, "webconsole", false); openToolbox(globals, true, "webconsole", false);
} }
}; };
a.title = a.textContent = window.l10n.GetStringFromName("mainProcess"); a.title = a.textContent = L10N.getStr("mainProcess");
a.className = "remote-process"; a.className = "remote-process";
a.href = "#"; a.href = "#";
gParent.appendChild(a); gParent.appendChild(a);

Просмотреть файл

@ -30,7 +30,8 @@ loader.lazyRequireGetter(this, "BrowserMenus", "devtools/client/framework/browse
loader.lazyImporter(this, "CustomizableUI", "resource:///modules/CustomizableUI.jsm"); loader.lazyImporter(this, "CustomizableUI", "resource:///modules/CustomizableUI.jsm");
loader.lazyImporter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm"); loader.lazyImporter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
const bundle = Services.strings.createBundle("chrome://devtools/locale/toolbox.properties"); const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
const TABS_OPEN_PEAK_HISTOGRAM = "DEVTOOLS_TABS_OPEN_PEAK_LINEAR"; const TABS_OPEN_PEAK_HISTOGRAM = "DEVTOOLS_TABS_OPEN_PEAK_LINEAR";
const TABS_OPEN_AVG_HISTOGRAM = "DEVTOOLS_TABS_OPEN_AVERAGE_LINEAR"; const TABS_OPEN_AVG_HISTOGRAM = "DEVTOOLS_TABS_OPEN_AVERAGE_LINEAR";
@ -244,7 +245,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
// Do nothing if there is only one process, the parent process. // Do nothing if there is only one process, the parent process.
let contentProcesses = response.processes.filter(p => (!p.parent)); let contentProcesses = response.processes.filter(p => (!p.parent));
if (contentProcesses.length < 1) { if (contentProcesses.length < 1) {
let msg = bundle.GetStringFromName("toolbox.noContentProcess.message"); let msg = L10N.getStr("toolbox.noContentProcess.message");
Services.prompt.alert(null, "", msg); Services.prompt.alert(null, "", msg);
deferred.reject("No content processes available."); deferred.reject("No content processes available.");
return; return;

Просмотреть файл

@ -4,12 +4,14 @@
"use strict"; "use strict";
var {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
var Services = require("Services"); var Services = require("Services");
var {Task} = require("devtools/shared/task"); var {Task} = require("devtools/shared/task");
var EventEmitter = require("devtools/shared/event-emitter"); var EventEmitter = require("devtools/shared/event-emitter");
var Telemetry = require("devtools/client/shared/telemetry"); var Telemetry = require("devtools/client/shared/telemetry");
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
/** /**
@ -130,7 +132,8 @@ ToolSidebar.prototype = {
this._allTabsBtn.setAttribute("top", "0"); this._allTabsBtn.setAttribute("top", "0");
this._allTabsBtn.setAttribute("width", "15"); this._allTabsBtn.setAttribute("width", "15");
this._allTabsBtn.setAttribute("type", "menu"); this._allTabsBtn.setAttribute("type", "menu");
this._allTabsBtn.setAttribute("tooltiptext", l10n("sidebar.showAllTabs.tooltip")); this._allTabsBtn.setAttribute("tooltiptext",
L10N.getStr("sidebar.showAllTabs.tooltip"));
this._allTabsBtn.setAttribute("hidden", "true"); this._allTabsBtn.setAttribute("hidden", "true");
allTabsContainer.appendChild(this._allTabsBtn); allTabsContainer.appendChild(this._allTabsBtn);
@ -587,19 +590,3 @@ ToolSidebar.prototype = {
this._toolPanel = null; this._toolPanel = null;
}) })
}; };
XPCOMUtils.defineLazyGetter(this, "l10n", function () {
let bundle = Services.strings.createBundle("chrome://devtools/locale/toolbox.properties");
let l10n = function (aName, ...aArgs) {
try {
if (aArgs.length == 0) {
return bundle.GetStringFromName(aName);
} else {
return bundle.formatStringFromName(aName, aArgs, aArgs.length);
}
} catch (ex) {
console.log("Error reading '" + aName + "'");
}
};
return l10n;
});

Просмотреть файл

@ -10,8 +10,9 @@
const URL = "data:text/html;charset=utf8,test page"; const URL = "data:text/html;charset=utf8,test page";
var {Toolbox} = require("devtools/client/framework/toolbox"); var {Toolbox} = require("devtools/client/framework/toolbox");
var strings = Services.strings.createBundle(
"chrome://devtools/locale/toolbox.properties"); const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
function getZoomValue() { function getZoomValue() {
return parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue")); return parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue"));
@ -39,7 +40,7 @@ add_task(function* () {
}); });
function zoomWithKey(toolbox, key) { function zoomWithKey(toolbox, key) {
let shortcut = strings.GetStringFromName(key); let shortcut = L10N.getStr(key);
if (!shortcut) { if (!shortcut) {
info("Key was empty, skipping zoomWithKey"); info("Key was empty, skipping zoomWithKey");
return; return;

Просмотреть файл

@ -11,8 +11,9 @@
const URL = "data:text/html;charset=utf8,test page for toolbox switching"; const URL = "data:text/html;charset=utf8,test page for toolbox switching";
var {Toolbox} = require("devtools/client/framework/toolbox"); var {Toolbox} = require("devtools/client/framework/toolbox");
var strings = Services.strings.createBundle(
"chrome://devtools/locale/toolbox.properties"); const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
add_task(function* () { add_task(function* () {
info("Create a test tab and open the toolbox"); info("Create a test tab and open the toolbox");
@ -20,7 +21,7 @@ add_task(function* () {
let target = TargetFactory.forTab(tab); let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "webconsole"); let toolbox = yield gDevTools.showToolbox(target, "webconsole");
let shortcut = strings.GetStringFromName("toolbox.toggleHost.key"); let shortcut = L10N.getStr("toolbox.toggleHost.key");
let {SIDE, BOTTOM, WINDOW} = Toolbox.HostType; let {SIDE, BOTTOM, WINDOW} = Toolbox.HostType;
checkHostType(toolbox, BOTTOM, SIDE); checkHostType(toolbox, BOTTOM, SIDE);

Просмотреть файл

@ -10,8 +10,8 @@
// and toggles appropriate things in the toolbox. // and toggles appropriate things in the toolbox.
var doc = null, toolbox = null, panelWin = null, modifiedPrefs = []; var doc = null, toolbox = null, panelWin = null, modifiedPrefs = [];
var strings = Services.strings.createBundle( const {LocalizationHelper} = require("devtools/shared/l10n");
"chrome://devtools/locale/toolbox.properties"); const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
add_task(function* () { add_task(function* () {
const URL = "data:text/html;charset=utf8,test for dynamically registering " + const URL = "data:text/html;charset=utf8,test for dynamically registering " +
@ -60,18 +60,18 @@ function* testOptionsShortcut() {
yield toolbox.selectTool("webconsole"); yield toolbox.selectTool("webconsole");
is(toolbox.currentToolId, "webconsole", "webconsole is selected"); is(toolbox.currentToolId, "webconsole", "webconsole is selected");
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.options.key")); synthesizeKeyShortcut(L10N.getStr("toolbox.options.key"));
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)"); is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)");
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.options.key")); synthesizeKeyShortcut(L10N.getStr("toolbox.options.key"));
is(toolbox.currentToolId, "webconsole", "webconsole is selected (1)"); is(toolbox.currentToolId, "webconsole", "webconsole is selected (1)");
yield toolbox.selectTool("webconsole"); yield toolbox.selectTool("webconsole");
is(toolbox.currentToolId, "webconsole", "webconsole is selected"); is(toolbox.currentToolId, "webconsole", "webconsole is selected");
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.help.key")); synthesizeKeyShortcut(L10N.getStr("toolbox.help.key"));
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)"); is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.options.key")); synthesizeKeyShortcut(L10N.getStr("toolbox.options.key"));
is(toolbox.currentToolId, "webconsole", "webconsole is reselected (2)"); is(toolbox.currentToolId, "webconsole", "webconsole is reselected (2)");
synthesizeKeyShortcut(strings.GetStringFromName("toolbox.help.key")); synthesizeKeyShortcut(L10N.getStr("toolbox.help.key"));
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)"); is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
} }

Просмотреть файл

@ -3,11 +3,14 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
requestLongerTimeout(2); requestLongerTimeout(2);
var {Toolbox} = require("devtools/client/framework/toolbox"); var {Toolbox} = require("devtools/client/framework/toolbox");
var strings = Services.strings.createBundle(
"chrome://devtools/locale/toolbox.properties"); const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
add_task(function* () { add_task(function* () {
let tab = yield addTab("about:blank"); let tab = yield addTab("about:blank");
@ -18,10 +21,9 @@ add_task(function* () {
.filter(def => def.isTargetSupported(target)) .filter(def => def.isTargetSupported(target))
.map(def => def.id); .map(def => def.id);
let toolbox = yield gDevTools.showToolbox(target, toolIDs[0], let toolbox = yield gDevTools.showToolbox(target, toolIDs[0], Toolbox.HostType.BOTTOM);
Toolbox.HostType.BOTTOM); let nextShortcut = L10N.getStr("toolbox.nextTool.key");
let nextShortcut = strings.GetStringFromName("toolbox.nextTool.key") let prevShortcut = L10N.getStr("toolbox.previousTool.key");
let prevShortcut = strings.GetStringFromName("toolbox.previousTool.key")
// Iterate over all tools, starting from options to netmonitor, in normal // Iterate over all tools, starting from options to netmonitor, in normal
// order. // order.

Просмотреть файл

@ -10,8 +10,9 @@ const TEST_URL = "data:text/html;charset=utf-8," +
"<body><h1>Testing reload from devtools</h1></body></html>"; "<body><h1>Testing reload from devtools</h1></body></html>";
var {Toolbox} = require("devtools/client/framework/toolbox"); var {Toolbox} = require("devtools/client/framework/toolbox");
var strings = Services.strings.createBundle(
"chrome://devtools/locale/toolbox.properties"); const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
var target, toolbox, description, reloadsSent, toolIDs; var target, toolbox, description, reloadsSent, toolIDs;
@ -83,7 +84,7 @@ function testReload(shortcut, docked, toolID, callback) {
description = docked + " devtools with tool " + toolID + ", shortcut #" + shortcut; description = docked + " devtools with tool " + toolID + ", shortcut #" + shortcut;
info("Testing reload in " + description); info("Testing reload in " + description);
synthesizeKeyShortcut(strings.GetStringFromName(shortcut), toolbox.win); synthesizeKeyShortcut(L10N.getStr(shortcut), toolbox.win);
reloadsSent++; reloadsSent++;
} }

Просмотреть файл

@ -3,13 +3,12 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
var modifiers = { "use strict";
accelKey: true
};
var toolbox; var toolbox;
var strings = Services.strings.createBundle(
"chrome://devtools/locale/toolbox.properties"); const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
function test() { function test() {
addTab("about:blank").then(openToolbox); addTab("about:blank").then(openToolbox);
@ -48,7 +47,7 @@ function testZoomLevel(type, times, expected) {
function sendZoomKey(shortcut, times) { function sendZoomKey(shortcut, times) {
for (let i = 0; i < times; i++) { for (let i = 0; i < times; i++) {
synthesizeKeyShortcut(strings.GetStringFromName(shortcut)); synthesizeKeyShortcut(L10N.getStr(shortcut));
} }
} }
@ -61,7 +60,7 @@ function tidyUp() {
toolbox.destroy().then(function () { toolbox.destroy().then(function () {
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
toolbox = modifiers = null; toolbox = null;
finish(); finish();
}); });
} }

Просмотреть файл

@ -8,26 +8,13 @@
const Services = require("Services"); const Services = require("Services");
const defer = require("devtools/shared/defer"); const defer = require("devtools/shared/defer");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const {Task} = require("devtools/shared/task"); const {Task} = require("devtools/shared/task");
const {gDevTools} = require("devtools/client/framework/devtools"); const {gDevTools} = require("devtools/client/framework/devtools");
exports.OptionsPanel = OptionsPanel; const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
XPCOMUtils.defineLazyGetter(this, "l10n", function () { exports.OptionsPanel = OptionsPanel;
let bundle = Services.strings.createBundle("chrome://devtools/locale/toolbox.properties");
let l10n = function (name, ...aArgs) {
try {
if (aArgs.length == 0) {
return bundle.GetStringFromName(name);
}
return bundle.formatStringFromName(name, aArgs, aArgs.length);
} catch (ex) {
console.log("Error reading '" + name + "'");
}
};
return l10n;
});
function GetPref(name) { function GetPref(name) {
let type = Services.prefs.getPrefType(name); let type = Services.prefs.getPrefType(name);
@ -220,8 +207,8 @@ OptionsPanel.prototype = {
checkboxSpanLabel.textContent = tool.label; checkboxSpanLabel.textContent = tool.label;
} else { } else {
atleastOneToolNotSupported = true; atleastOneToolNotSupported = true;
checkboxSpanLabel.textContent = l10n( checkboxSpanLabel.textContent =
"options.toolNotSupportedMarker", tool.label); L10N.getFormatStr("options.toolNotSupportedMarker", tool.label);
checkboxInput.setAttribute("data-unsupported", "true"); checkboxInput.setAttribute("data-unsupported", "true");
checkboxInput.setAttribute("disabled", "true"); checkboxInput.setAttribute("disabled", "true");
} }

Просмотреть файл

@ -32,21 +32,9 @@ const { KeyCodes } = require("devtools/client/shared/keycodes");
const { BrowserLoader } = const { BrowserLoader } =
Cu.import("resource://devtools/client/shared/browser-loader.js", {}); Cu.import("resource://devtools/client/shared/browser-loader.js", {});
loader.lazyGetter(this, "toolboxStrings", () => { const {LocalizationHelper} = require("devtools/shared/l10n");
const properties = "chrome://devtools/locale/toolbox.properties"; const L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
const bundle = Services.strings.createBundle(properties);
return (name, ...args) => {
try {
if (!args.length) {
return bundle.GetStringFromName(name);
}
return bundle.formatStringFromName(name, args, args.length);
} catch (ex) {
console.log("Error reading '" + name + "'");
return null;
}
};
});
loader.lazyRequireGetter(this, "CommandUtils", loader.lazyRequireGetter(this, "CommandUtils",
"devtools/client/shared/developer-toolbar", true); "devtools/client/shared/developer-toolbar", true);
loader.lazyRequireGetter(this, "getHighlighterUtils", loader.lazyRequireGetter(this, "getHighlighterUtils",
@ -386,7 +374,7 @@ Toolbox.prototype = {
useOnlyShared: true useOnlyShared: true
}).require; }).require;
iframe.setAttribute("aria-label", toolboxStrings("toolbox.label")); iframe.setAttribute("aria-label", L10N.getStr("toolbox.label"));
let domHelper = new DOMHelpers(iframe.contentWindow); let domHelper = new DOMHelpers(iframe.contentWindow);
domHelper.onceDOMReady(() => { domHelper.onceDOMReady(() => {
domReady.resolve(); domReady.resolve();
@ -545,8 +533,8 @@ Toolbox.prototype = {
// Prevent the opening of bookmarks window on toolbox.options.key // Prevent the opening of bookmarks window on toolbox.options.key
event.preventDefault(); event.preventDefault();
}; };
shortcuts.on(toolboxStrings("toolbox.options.key"), selectOptions); shortcuts.on(L10N.getStr("toolbox.options.key"), selectOptions);
shortcuts.on(toolboxStrings("toolbox.help.key"), selectOptions); shortcuts.on(L10N.getStr("toolbox.help.key"), selectOptions);
}, },
_splitConsoleOnKeypress: function (e) { _splitConsoleOnKeypress: function (e) {
@ -591,7 +579,7 @@ Toolbox.prototype = {
["forceReload", true], ["forceReload", true],
["forceReload2", true] ["forceReload2", true]
].forEach(([id, force]) => { ].forEach(([id, force]) => {
let key = toolboxStrings("toolbox." + id + ".key"); let key = L10N.getStr("toolbox." + id + ".key");
shortcuts.on(key, (name, event) => { shortcuts.on(key, (name, event) => {
this.reloadTarget(force); this.reloadTarget(force);
@ -602,13 +590,13 @@ Toolbox.prototype = {
}, },
_addHostListeners: function (shortcuts) { _addHostListeners: function (shortcuts) {
shortcuts.on(toolboxStrings("toolbox.nextTool.key"), shortcuts.on(L10N.getStr("toolbox.nextTool.key"),
this.selectNextTool.bind(this)); this.selectNextTool.bind(this));
shortcuts.on(toolboxStrings("toolbox.previousTool.key"), shortcuts.on(L10N.getStr("toolbox.previousTool.key"),
this.selectPreviousTool.bind(this)); this.selectPreviousTool.bind(this));
shortcuts.on(toolboxStrings("toolbox.minimize.key"), shortcuts.on(L10N.getStr("toolbox.minimize.key"),
this._toggleMinimizeMode.bind(this)); this._toggleMinimizeMode.bind(this));
shortcuts.on(toolboxStrings("toolbox.toggleHost.key"), shortcuts.on(L10N.getStr("toolbox.toggleHost.key"),
(name, event) => { (name, event) => {
this.switchToPreviousHost(); this.switchToPreviousHost();
event.preventDefault(); event.preventDefault();
@ -703,7 +691,7 @@ Toolbox.prototype = {
let key = doc.createElement("key"); let key = doc.createElement("key");
key.id = "key_browserconsole"; key.id = "key_browserconsole";
key.setAttribute("key", toolboxStrings("browserConsoleCmd.commandkey")); key.setAttribute("key", L10N.getStr("browserConsoleCmd.commandkey"));
key.setAttribute("modifiers", "accel,shift"); key.setAttribute("modifiers", "accel,shift");
// needed. See bug 371900 // needed. See bug 371900
key.setAttribute("oncommand", "void(0)"); key.setAttribute("oncommand", "void(0)");
@ -807,7 +795,7 @@ Toolbox.prototype = {
let button = this.doc.createElementNS(HTML_NS, "button"); let button = this.doc.createElementNS(HTML_NS, "button");
button.id = "toolbox-dock-" + position; button.id = "toolbox-dock-" + position;
button.className = "toolbox-dock-button devtools-button"; button.className = "toolbox-dock-button devtools-button";
button.setAttribute("title", toolboxStrings("toolboxDockButtons." + button.setAttribute("title", L10N.getStr("toolboxDockButtons." +
position + ".tooltip")); position + ".tooltip"));
button.addEventListener("click", () => { button.addEventListener("click", () => {
this.switchHost(position); this.switchHost(position);
@ -818,7 +806,7 @@ Toolbox.prototype = {
}, },
_getMinimizeButtonShortcutTooltip: function () { _getMinimizeButtonShortcutTooltip: function () {
let str = toolboxStrings("toolbox.minimize.key"); let str = L10N.getStr("toolbox.minimize.key");
let key = KeyShortcuts.parseElectronKey(this.win, str); let key = KeyShortcuts.parseElectronKey(this.win, str);
return "(" + KeyShortcuts.stringify(key) + ")"; return "(" + KeyShortcuts.stringify(key) + ")";
}, },
@ -828,7 +816,7 @@ Toolbox.prototype = {
btn.className = "minimized"; btn.className = "minimized";
btn.setAttribute("title", btn.setAttribute("title",
toolboxStrings("toolboxDockButtons.bottom.maximize") + " " + L10N.getStr("toolboxDockButtons.bottom.maximize") + " " +
this._getMinimizeButtonShortcutTooltip()); this._getMinimizeButtonShortcutTooltip());
}, },
@ -837,7 +825,7 @@ Toolbox.prototype = {
btn.className = "maximized"; btn.className = "maximized";
btn.setAttribute("title", btn.setAttribute("title",
toolboxStrings("toolboxDockButtons.bottom.minimize") + " " + L10N.getStr("toolboxDockButtons.bottom.minimize") + " " +
this._getMinimizeButtonShortcutTooltip()); this._getMinimizeButtonShortcutTooltip());
}, },
@ -985,7 +973,7 @@ Toolbox.prototype = {
this._pickerButton = this.doc.createElementNS(HTML_NS, "button"); this._pickerButton = this.doc.createElementNS(HTML_NS, "button");
this._pickerButton.id = "command-button-pick"; this._pickerButton.id = "command-button-pick";
this._pickerButton.className = "command-button command-button-invertable devtools-button"; this._pickerButton.className = "command-button command-button-invertable devtools-button";
this._pickerButton.setAttribute("title", toolboxStrings("pickButton.tooltip")); this._pickerButton.setAttribute("title", L10N.getStr("pickButton.tooltip"));
this._pickerButton.setAttribute("hidden", "true"); this._pickerButton.setAttribute("hidden", "true");
let container = this.doc.querySelector("#toolbox-picker-container"); let container = this.doc.querySelector("#toolbox-picker-container");
@ -1577,10 +1565,10 @@ Toolbox.prototype = {
_refreshHostTitle: function () { _refreshHostTitle: function () {
let title; let title;
if (this.target.name && this.target.name != this.target.url) { if (this.target.name && this.target.name != this.target.url) {
title = toolboxStrings("toolbox.titleTemplate2", title = L10N.getFormatStr("toolbox.titleTemplate2", this.target.name,
this.target.name, this.target.url); this.target.url);
} else { } else {
title = toolboxStrings("toolbox.titleTemplate1", this.target.url); title = L10N.getFormatStr("toolbox.titleTemplate1", this.target.url);
} }
this._host.setTitle(title); this._host.setTitle(title);
}, },
@ -1588,7 +1576,7 @@ Toolbox.prototype = {
// Returns an instance of the preference actor // Returns an instance of the preference actor
get _preferenceFront() { get _preferenceFront() {
return this.target.root.then(rootForm => { return this.target.root.then(rootForm => {
return new getPreferenceFront(this.target.client, rootForm); return new L10N.getFormatStr(this.target.client, rootForm);
}); });
}, },