From 9a0a15abbeb885c4b449cd474770651ac0661c62 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 11 Jan 2024 15:51:19 -0500 Subject: [PATCH] Don't show string "PLACEHOLDER" in menu while localization runs Ideally we should cache these/not recreate the menuitems every time, or something like that, so that localization pop-in doesn't happen at all. But a brief flash of an empty menuitem is better than a brief flash of placeholder text. --- chrome/content/zotero/locateMenu.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/locateMenu.js b/chrome/content/zotero/locateMenu.js index de94799745..54e93cfab2 100644 --- a/chrome/content/zotero/locateMenu.js +++ b/chrome/content/zotero/locateMenu.js @@ -121,14 +121,22 @@ var Zotero_LocateMenu = new function() { }); function _addViewOption(selectedItems, optionName, optionObject, showIcons) { - var menuitem = _createMenuItem(optionObject.label || Zotero.getString(`locate.${optionName}.label`), - null, null); + var menuitem; + if (optionObject.l10nKey) { + menuitem = _createMenuItem('', null, null); // Set by Fluent + menuitem.setAttribute("data-l10n-id", optionObject.l10nKey); + if (optionObject.l10nArgs) { + menuitem.setAttribute("data-l10n-args", optionObject.l10nArgs); + } + } + else { + menuitem = _createMenuItem(optionObject.label || Zotero.getString(`locate.${optionName}.label`), + null, null); + } if (optionObject.className && showIcons) { menuitem.setAttribute("class", `menuitem-iconic ${optionObject.className}`); } menuitem.setAttribute("zotero-locate", "true"); - optionObject.l10nKey && menuitem.setAttribute("data-l10n-id", optionObject.l10nKey); - optionObject.l10nArgs && menuitem.setAttribute("data-l10n-args", optionObject.l10nArgs); menuitem.addEventListener("command", function (event) { optionObject.handleItems(selectedItems, event); @@ -377,8 +385,6 @@ var Zotero_LocateMenu = new function() { // "in New Tab" when it's true) in toolbar Locate menu this.hideInToolbar = alternateWindowBehavior; - // Must have a label, otherwise an error is thrown in `Zotero.getString` - this.label = "PLACEHOLDER"; this.l10nKey = "item-menu-viewAttachment"; Object.defineProperty(this, "l10nArgs", { get: () => JSON.stringify({