зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1655672 - Fix l10n for one-off tooltips with aliases. r=harry,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D85125
This commit is contained in:
Родитель
bfb67baaf1
Коммит
311fa7e378
|
@ -515,6 +515,7 @@ class SearchOneOffs {
|
|||
for (let i = 0; i < engines.length; ++i) {
|
||||
let engine = engines[i];
|
||||
let button = this.document.createXULElement("button");
|
||||
button.engine = engine;
|
||||
button.id = this._buttonIDForEngine(engine);
|
||||
let uri = "chrome://browser/skin/search-engine-placeholder.png";
|
||||
if (engine.iconURI) {
|
||||
|
@ -522,8 +523,7 @@ class SearchOneOffs {
|
|||
}
|
||||
button.setAttribute("image", uri);
|
||||
button.setAttribute("class", "searchbar-engine-one-off-item");
|
||||
button.setAttribute("tooltiptext", this.tooltipForEngine(engine));
|
||||
button.engine = engine;
|
||||
this.setTooltipForEngineButton(button);
|
||||
|
||||
this.buttons.appendChild(button);
|
||||
}
|
||||
|
@ -1094,14 +1094,14 @@ class SearchOneOffs {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the tooltip for the one-off button of an engine.
|
||||
* Sets the tooltip for a one-off button with an engine. This should set
|
||||
* either the `tooltiptext` attribute or the relevant l10n ID.
|
||||
*
|
||||
* @param {nsISearchEngine|SearchEngine} engine
|
||||
* The engine.
|
||||
* @returns {string} The tooltip for the given engine.
|
||||
* @param {element} button
|
||||
* The one-off button.
|
||||
*/
|
||||
tooltipForEngine(engine) {
|
||||
return engine.name;
|
||||
setTooltipForEngineButton(button) {
|
||||
button.setAttribute("tooltiptext", button.engine.name);
|
||||
}
|
||||
|
||||
// Event handlers below.
|
||||
|
|
|
@ -129,19 +129,25 @@ class UrlbarSearchOneOffs extends SearchOneOffs {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the tooltip for the one-off button of an engine.
|
||||
* Sets the tooltip for a one-off button with an engine. This should set
|
||||
* either the `tooltiptext` attribute or the relevant l10n ID.
|
||||
*
|
||||
* @param {nsISearchEngine|SearchEngine} engine
|
||||
* The engine.
|
||||
* @returns {string}
|
||||
* The tooltip for the given engine.
|
||||
* @param {element} button
|
||||
* The one-off button.
|
||||
*/
|
||||
tooltipForEngine(engine) {
|
||||
let tooltip = engine.name;
|
||||
let aliases = UrlbarSearchUtils.aliasesForEngine(engine);
|
||||
if (aliases.length) {
|
||||
tooltip += ` (${aliases[0]})`;
|
||||
setTooltipForEngineButton(button) {
|
||||
let aliases = UrlbarSearchUtils.aliasesForEngine(button.engine);
|
||||
if (!aliases.length) {
|
||||
super.setTooltipForEngineButton(button);
|
||||
return;
|
||||
}
|
||||
return tooltip;
|
||||
this.document.l10n.setAttributes(
|
||||
button,
|
||||
"search-one-offs-engine-with-alias",
|
||||
{
|
||||
engineName: button.engine.name,
|
||||
alias: aliases[0],
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,6 +190,13 @@ search-one-offs-context-set-as-default-private =
|
|||
.label = Set as Default Search Engine for Private Windows
|
||||
.accesskey = P
|
||||
|
||||
# Search engine one-off buttons with an @alias shortcut/keyword.
|
||||
# Variables:
|
||||
# $engineName (String): The name of the engine.
|
||||
# $alias (String): The @alias shortcut/keyword.
|
||||
search-one-offs-engine-with-alias =
|
||||
.tooltiptext = { $engineName } ({ $alias })
|
||||
|
||||
## Bookmark Panel
|
||||
|
||||
bookmark-panel-show-editor-checkbox =
|
||||
|
|
Загрузка…
Ссылка в новой задаче