Bug 1768567 - Fix missing plus sign in the fluent strings of the global shortcuts file and create a string mapping for easier update. r=mkmelin
Differential Revision:
https://phabricator.services.mozilla.com/D146599
--- a/mail/locales/en-US/messenger/shortcuts.ftl
+++ b/mail/locales/en-US/messenger/shortcuts.ftl
@@ -75,32 +75,32 @@ meta-ctrl-shift-shortcut-key = {
}
alt-shift-shortcut-key = {
PLATFORM() ->
[macos] ⌥ ⇧ { $key }
*[other] Alt+Shift+{ $key }
}
-meta-shift-alt-shortcut-key = {
+meta-shift-alt-shortcut-key2 = {
PLATFORM() ->
[macos] ⌥ ⇧ ⌘ { $key }
- *[other] Meta+Alt+Shift{ $key }
+ *[other] Meta+Alt+Shift+{ $key }
}
-ctrl-shift-alt-shortcut-key = {
+ctrl-shift-alt-shortcut-key2 = {
PLATFORM() ->
[macos] ⌃ ⌥ ⇧ { $key }
- *[other] Ctrl+Alt+Shift{ $key }
+ *[other] Ctrl+Alt+Shift+{ $key }
}
-meta-ctrl-shift-alt-shortcut-key = {
+meta-ctrl-shift-alt-shortcut-key2 = {
PLATFORM() ->
[macos] ⌃ ⌥ ⇧ ⌘ { $key }
- *[other] Meta+Ctrl+Alt+Shift{ $key }
+ *[other] Meta+Ctrl+Alt+Shift+{ $key }
}
# Variables:
# $title (String): The title coming from the original element.
# $shortcut (String): The shortcut generated from the keystroke combination.
button-shortcut-string =
.title = { $title } ({ $shortcut })
--- a/mail/modules/ShortcutsManager.jsm
+++ b/mail/modules/ShortcutsManager.jsm
@@ -12,16 +12,29 @@
const EXPORTED_SYMBOLS = ["ShortcutsManager"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const ShortcutsManager = {
/**
+ * Fluent strings mapping to allow updating strings without changing all the
+ * IDs in the shortcuts.ftl file. This is needed because the IDs are
+ * dynamically generated.
+ *
+ * @type {Object}
+ */
+ fluentMapping: {
+ "meta-shift-alt-shortcut-key": "meta-shift-alt-shortcut-key2",
+ "ctrl-shift-alt-shortcut-key": "ctrl-shift-alt-shortcut-key2",
+ "meta-ctrl-shift-alt-shortcut-key": "meta-ctrl-shift-alt-shortcut-key2",
+ },
+
+ /**
* Data set for a shortcut.
*
* @typedef {Object} Shortcut
* @property {string} id - The id for this shortcut.
* @property {string} name - The name of this shortcut. TODO: This should use
* fluent to be translatable in the future, once we decide to expose this
* array and make it customizable.
* @property {?string} key - The keyboard key used by this shortcut, or null
@@ -305,17 +318,21 @@ const ShortcutsManager = {
if (shortcut.modifiers[platform].altKey) {
string.push("alt");
aria.push("Alt");
}
string.push("shortcut-key");
aria.push(shortcut.key.toUpperCase());
- let value = await this.l10n.formatValue(string.join("-"), {
+ // Check if the ID was updated in the fluent file and replace it.
+ let stringId = string.join("-");
+ stringId = this.fluentMapping[stringId] || stringId;
+
+ let value = await this.l10n.formatValue(stringId, {
key: shortcut.key.toUpperCase(),
});
return { localizedShortcut: value, ariaKeyShortcuts: aria.join("+") };
},
};
XPCOMUtils.defineLazyGetter(