From e9c35b0f927ed044e426a71758eda7c72d2fb6e0 Mon Sep 17 00:00:00 2001 From: InlitX Date: Sun, 5 Jul 2026 12:19:18 +0200 Subject: [PATCH] gh-10749: Localize command palette actions, emoji picker, etc (gh-14473) --- crowdin.yml | 2 + .../browser/browser/zen-command-palette.ftl | 36 ++++++++++ locales/en-US/browser/browser/zen-general.ftl | 2 + .../base/content/zen-panels/emojis-picker.inc | 2 +- src/zen/spaces/ZenSpaceCreation.mjs | 2 +- src/zen/urlbar/ZenUBActionsProvider.sys.mjs | 8 ++- src/zen/urlbar/ZenUBGlobalActions.sys.mjs | 69 ++++++++++--------- 7 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 locales/en-US/browser/browser/zen-command-palette.ftl diff --git a/crowdin.yml b/crowdin.yml index 964f52d44..2fd87a2fc 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -24,3 +24,5 @@ files: translation: browser/browser/zen-boosts.ftl - source: en-US/browser/browser/zen-space-routing.ftl translation: browser/browser/zen-space-routing.ftl + - source: en-US/browser/browser/zen-command-palette.ftl + translation: browser/browser/zen-command-palette.ftl diff --git a/locales/en-US/browser/browser/zen-command-palette.ftl b/locales/en-US/browser/browser/zen-command-palette.ftl new file mode 100644 index 000000000..c8af413e2 --- /dev/null +++ b/locales/en-US/browser/browser/zen-command-palette.ftl @@ -0,0 +1,36 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +zen-action-toggle-compact-mode = Toggle Compact Mode +zen-action-open-theme-picker = Open Theme Picker +zen-action-new-split-view = New Split View +zen-action-new-folder = New Folder +zen-action-copy-current-url = Copy Current URL +zen-action-settings = Settings +zen-action-open-private-window = Open Private Window +zen-action-open-new-window = Open New Window +zen-action-new-blank-window = New Blank Window +zen-action-pin-tab = Pin Tab +zen-action-unpin-tab = Unpin Tab +zen-action-open-space-routing = Open Space Routing +zen-action-new-boost = New Boost +zen-action-next-space = Next Space +zen-action-previous-space = Previous Space +zen-action-close-tab = Close Tab +zen-action-reload-tab = Reload Tab +zen-action-reload-tab-without-cache = Reload Tab Without Cache +zen-action-next-tab = Next Tab +zen-action-previous-tab = Previous Tab +zen-action-capture-screenshot = Capture Screenshot +zen-action-toggle-tabs-on-right = Toggle Tabs on right +zen-action-add-to-essentials = Add to Essentials +zen-action-remove-from-essentials = Remove from Essentials +zen-action-find-in-page = Find in Page +zen-action-manage-extensions = Manage Extensions +zen-action-switch-to-automatic-appearance = Switch to Automatic Appearance +zen-action-switch-to-light-mode = Switch to Light Mode +zen-action-switch-to-dark-mode = Switch to Dark Mode +zen-action-print = Print +zen-action-focus-on = Focus on +zen-action-extension = Extension diff --git a/locales/en-US/browser/browser/zen-general.ftl b/locales/en-US/browser/browser/zen-general.ftl index cf6c3b95b..93bf074f1 100644 --- a/locales/en-US/browser/browser/zen-general.ftl +++ b/locales/en-US/browser/browser/zen-general.ftl @@ -87,6 +87,8 @@ zen-icons-picker-emoji = .label = Emojis zen-icons-picker-svg = .label = Icons +zen-emojis-picker-search = + .placeholder = Search emojis urlbar-search-mode-zen_actions = Actions zen-site-data-settings = Settings diff --git a/src/browser/base/content/zen-panels/emojis-picker.inc b/src/browser/base/content/zen-panels/emojis-picker.inc index 1b8a35ec6..2bc42e234 100644 --- a/src/browser/base/content/zen-panels/emojis-picker.inc +++ b/src/browser/base/content/zen-panels/emojis-picker.inc @@ -14,7 +14,7 @@ - + diff --git a/src/zen/spaces/ZenSpaceCreation.mjs b/src/zen/spaces/ZenSpaceCreation.mjs index c84a5bf7b..52045f64a 100644 --- a/src/zen/spaces/ZenSpaceCreation.mjs +++ b/src/zen/spaces/ZenSpaceCreation.mjs @@ -192,7 +192,7 @@ class nsZenWorkspaceCreation extends MozXULElement { this.currentProfile = { id: 0, - name: "Default", + name: ContextualIdentityService.formatContextLabel("user-context-none"), }; } else { this.inputProfile.parentNode.hidden = true; diff --git a/src/zen/urlbar/ZenUBActionsProvider.sys.mjs b/src/zen/urlbar/ZenUBActionsProvider.sys.mjs index 6814e1261..08fa090b0 100644 --- a/src/zen/urlbar/ZenUBActionsProvider.sys.mjs +++ b/src/zen/urlbar/ZenUBActionsProvider.sys.mjs @@ -27,6 +27,10 @@ ChromeUtils.defineESModuleGetters(lazy, { UrlUtils: "resource://gre/modules/UrlUtils.sys.mjs", }); +ChromeUtils.defineLazyGetter(lazy, "l10n", () => { + return new Localization(["browser/zen-command-palette.ftl"], true); +}); + XPCOMUtils.defineLazyPreferenceGetter( lazy, "enabledPref", @@ -182,7 +186,7 @@ export class ZenUrlbarProviderGlobalActions extends UrlbarProvider { .workspaceElement(workspace.uuid) ?.style.getPropertyValue("--zen-primary-color"); actions.push({ - label: "Focus on", + label: lazy.l10n.formatValueSync("zen-action-focus-on"), extraPayload: { workspaceId: workspace.uuid, prettyName: workspace.name, @@ -215,7 +219,7 @@ export class ZenUrlbarProviderGlobalActions extends UrlbarProvider { .map(addon => { return { icon: "chrome://browser/skin/zen-icons/extension.svg", - label: "Extension", + label: lazy.l10n.formatValueSync("zen-action-extension"), commandId: `zen:extension-${addon.id}`, extraPayload: { extensionId: addon.id, diff --git a/src/zen/urlbar/ZenUBGlobalActions.sys.mjs b/src/zen/urlbar/ZenUBGlobalActions.sys.mjs index 613c0073f..517938ec5 100644 --- a/src/zen/urlbar/ZenUBGlobalActions.sys.mjs +++ b/src/zen/urlbar/ZenUBGlobalActions.sys.mjs @@ -13,58 +13,62 @@ XPCOMUtils.defineLazyPreferenceGetter( 2 ); +ChromeUtils.defineLazyGetter(lazy, "l10n", () => { + return new Localization(["browser/zen-command-palette.ftl"], true); +}); + function isNotEmptyTab(window) { return !window.gBrowser.selectedTab.hasAttribute("zen-empty-tab"); } const globalActionsTemplate = [ { - label: "Toggle Compact Mode", + l10nId: "zen-action-toggle-compact-mode", command: "cmd_zenCompactModeToggle", icon: "chrome://browser/skin/zen-icons/sidebar.svg", }, { - label: "Open Theme Picker", + l10nId: "zen-action-open-theme-picker", command: "cmd_zenOpenZenThemePicker", icon: "chrome://browser/skin/zen-icons/edit-theme.svg", }, { - label: "New Split View", + l10nId: "zen-action-new-split-view", command: "cmd_zenNewEmptySplit", icon: "chrome://browser/skin/zen-icons/split.svg", }, { - label: "New Folder", + l10nId: "zen-action-new-folder", command: "cmd_zenOpenFolderCreation", icon: "chrome://browser/skin/zen-icons/folder.svg", }, { - label: "Copy Current URL", + l10nId: "zen-action-copy-current-url", command: "cmd_zenCopyCurrentURL", icon: "chrome://browser/skin/zen-icons/link.svg", }, { - label: "Settings", + l10nId: "zen-action-settings", command: window => window.openPreferences(), icon: "chrome://browser/skin/zen-icons/settings.svg", }, { - label: "Open Private Window", + l10nId: "zen-action-open-private-window", command: "Tools:PrivateBrowsing", icon: "chrome://browser/skin/zen-icons/private-window.svg", }, { - label: "Open New Window", + l10nId: "zen-action-open-new-window", command: "cmd_newNavigator", icon: "chrome://browser/skin/zen-icons/window.svg", }, { - label: "New Blank Window", + l10nId: "zen-action-new-blank-window", command: "cmd_zenNewNavigatorUnsynced", icon: "chrome://browser/skin/zen-icons/window.svg", }, { - label: "Pin Tab", + l10nId: "zen-action-pin-tab", command: "cmd_zenTogglePinTab", icon: "chrome://browser/skin/zen-icons/pin.svg", isAvailable: window => { @@ -73,7 +77,7 @@ const globalActionsTemplate = [ }, }, { - label: "Unpin Tab", + l10nId: "zen-action-unpin-tab", command: "cmd_zenTogglePinTab", icon: "chrome://browser/skin/zen-icons/unpin.svg", isAvailable: window => { @@ -82,12 +86,12 @@ const globalActionsTemplate = [ }, }, { - label: "Open Space Routing", + l10nId: "zen-action-open-space-routing", command: "cmd_zenOpenSpaceRoutingSettings", icon: "chrome://browser/skin/zen-icons/selectable/airplane.svg", }, { - label: "New Boost", + l10nId: "zen-action-new-boost", icon: "chrome://browser/skin/zen-icons/boost.svg", isAvailable: window => { if (!isNotEmptyTab(window)) { @@ -130,7 +134,7 @@ const globalActionsTemplate = [ }, }, { - label: "Next Space", + l10nId: "zen-action-next-space", command: "cmd_zenWorkspaceForward", icon: "chrome://browser/skin/zen-icons/forward.svg", isAvailable: window => { @@ -138,7 +142,7 @@ const globalActionsTemplate = [ }, }, { - label: "Previous Space", + l10nId: "zen-action-previous-space", command: "cmd_zenWorkspaceBackward", icon: "chrome://browser/skin/zen-icons/back.svg", isAvailable: window => { @@ -147,7 +151,7 @@ const globalActionsTemplate = [ }, }, { - label: "Close Tab", + l10nId: "zen-action-close-tab", command: "cmd_close", icon: "chrome://browser/skin/zen-icons/close.svg", isAvailable: window => { @@ -155,27 +159,27 @@ const globalActionsTemplate = [ }, }, { - label: "Reload Tab", + l10nId: "zen-action-reload-tab", command: "Browser:Reload", icon: "chrome://browser/skin/zen-icons/reload.svg", }, { - label: "Reload Tab Without Cache", + l10nId: "zen-action-reload-tab-without-cache", command: "Browser:ReloadSkipCache", icon: "chrome://browser/skin/zen-icons/reload.svg", }, { - label: "Next Tab", + l10nId: "zen-action-next-tab", command: "Browser:NextTab", icon: "chrome://browser/skin/zen-icons/forward.svg", }, { - label: "Previous Tab", + l10nId: "zen-action-previous-tab", command: "Browser:PrevTab", icon: "chrome://browser/skin/zen-icons/back.svg", }, { - label: "Capture Screenshot", + l10nId: "zen-action-capture-screenshot", command: "Browser:Screenshot", icon: "chrome://browser/skin/zen-icons/screenshot.svg", isAvailable: window => { @@ -183,12 +187,12 @@ const globalActionsTemplate = [ }, }, { - label: "Toggle Tabs on right", + l10nId: "zen-action-toggle-tabs-on-right", command: "cmd_zenToggleTabsOnRight", icon: "chrome://browser/skin/zen-icons/sidebars-right.svg", }, { - label: "Add to Essentials", + l10nId: "zen-action-add-to-essentials", command: window => window.gZenPinnedTabManager.addToEssentials(window.gBrowser.selectedTab), isAvailable: window => { @@ -201,7 +205,7 @@ const globalActionsTemplate = [ icon: "chrome://browser/skin/zen-icons/essential-add.svg", }, { - label: "Remove from Essentials", + l10nId: "zen-action-remove-from-essentials", command: window => window.gZenPinnedTabManager.removeEssentials(window.gBrowser.selectedTab), isAvailable: window => @@ -209,7 +213,7 @@ const globalActionsTemplate = [ icon: "chrome://browser/skin/zen-icons/essential-remove.svg", }, { - label: "Find in Page", + l10nId: "zen-action-find-in-page", command: "cmd_find", icon: "chrome://browser/skin/zen-icons/search-page.svg", isAvailable: window => { @@ -217,12 +221,12 @@ const globalActionsTemplate = [ }, }, { - label: "Manage Extensions", + l10nId: "zen-action-manage-extensions", command: "Tools:Addons", icon: "chrome://browser/skin/zen-icons/extension.svg", }, { - label: "Switch to Automatic Appearance", + l10nId: "zen-action-switch-to-automatic-appearance", command: () => Services.prefs.setIntPref("zen.view.window.scheme", 2), icon: "chrome://browser/skin/zen-icons/sparkles.svg", isAvailable: () => { @@ -230,7 +234,7 @@ const globalActionsTemplate = [ }, }, { - label: "Switch to Light Mode", + l10nId: "zen-action-switch-to-light-mode", command: () => Services.prefs.setIntPref("zen.view.window.scheme", 1), icon: "chrome://browser/skin/zen-icons/face-sun.svg", isAvailable: () => { @@ -238,7 +242,7 @@ const globalActionsTemplate = [ }, }, { - label: "Switch to Dark Mode", + l10nId: "zen-action-switch-to-dark-mode", command: () => Services.prefs.setIntPref("zen.view.window.scheme", 0), icon: "chrome://browser/skin/zen-icons/moon-stars.svg", isAvailable: () => { @@ -246,7 +250,7 @@ const globalActionsTemplate = [ }, }, { - label: "Print", + l10nId: "zen-action-print", command: "cmd_print", icon: "chrome://browser/skin/zen-icons/print.svg", isAvailable: window => { @@ -266,7 +270,10 @@ export const globalActions = globalActionsTemplate.map(action => ({ commandId: typeof action.command === "string" ? action.command - : `zen:global-action-${action.label.toLowerCase().replace(/\s+/g, "-")}`, + : `zen:global-action-${action.l10nId.replace("zen-action-", "")}`, extraPayload: {}, ...action, + get label() { + return lazy.l10n.formatValueSync(action.l10nId); + }, }));