From eb383e63f13491266a1f93857f25a8a3a9ee6920 Mon Sep 17 00:00:00 2001 From: helloigig Date: Wed, 4 Nov 2026 01:20:57 +0000 Subject: [PATCH 1/2] Make the parameter help shortcut translatable The shortcut shown in the Manual parameter help option was built in code, so translators couldn't localise the key names (for example, Strg in German). Move it into two source strings, one for Mac and one for other platforms. English is unchanged and existing translations still apply. Closes #1193 --- lang/ui.en.json | 8 +++++ src/settings/SettingsArea.test.tsx | 52 ++++++++++++++++++++++++++++++ src/settings/SettingsArea.tsx | 6 +++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/settings/SettingsArea.test.tsx diff --git a/lang/ui.en.json b/lang/ui.en.json index d3ca33dce..4318f88b7 100644 --- a/lang/ui.en.json +++ b/lang/ui.en.json @@ -550,6 +550,14 @@ "defaultMessage": "Manual ({shortcut})", "description": "Parameter help setting for when the user must press a key combination to open the parameter documentation" }, + "parameter-help-shortcut": { + "defaultMessage": "Ctrl+Shift+Space", + "description": "Keyboard shortcut that opens parameter help on Windows, Linux and ChromeOS. Shown in brackets after the Manual parameter help setting. Use the key names printed on keyboards in your language." + }, + "parameter-help-shortcut-mac": { + "defaultMessage": "Cmd+Shift+Space", + "description": "Keyboard shortcut that opens parameter help on a Mac. Shown in brackets after the Manual parameter help setting. Use the key names printed on Mac keyboards in your language." + }, "permanently-delete": { "defaultMessage": "Permanently delete {filename}?", "description": "Confirmation question to permanently delete file" diff --git a/src/settings/SettingsArea.test.tsx b/src/settings/SettingsArea.test.tsx new file mode 100644 index 000000000..e3ee9e4a2 --- /dev/null +++ b/src/settings/SettingsArea.test.tsx @@ -0,0 +1,52 @@ +/** + * (c) 2026, Micro:bit Educational Foundation and contributors + * + * SPDX-License-Identifier: MIT + */ +import { render, screen } from "@testing-library/react"; +import { IntlProvider } from "react-intl"; +import { vi } from "vitest"; +import en from "../messages/ui.en.json"; +import SettingsArea from "./SettingsArea"; +import SettingsProvider from "./settings"; + +const renderSettingsArea = (messages: Record) => + render( + + + + + + ); + +describe("SettingsArea", () => { + afterEach(() => { + vi.unstubAllGlobals(); + }); + + it("uses the translated parameter help shortcut", () => { + vi.stubGlobal("navigator", { ...navigator, platform: "Win32" }); + renderSettingsArea({ + "parameter-help-manual": "Anleitung ({shortcut})", + "parameter-help-shortcut": "Strg+Umschalt+Leertaste", + }); + expect( + screen.getByRole("option", { + name: "Anleitung (Strg+Umschalt+Leertaste)", + }) + ).toBeDefined(); + }); + + it("uses the translated Mac parameter help shortcut on a Mac", () => { + vi.stubGlobal("navigator", { ...navigator, platform: "MacIntel" }); + renderSettingsArea({ + "parameter-help-manual": "Anleitung ({shortcut})", + "parameter-help-shortcut-mac": "Befehl+Umschalt+Leertaste", + }); + expect( + screen.getByRole("option", { + name: "Anleitung (Befehl+Umschalt+Leertaste)", + }) + ).toBeDefined(); + }); +}); diff --git a/src/settings/SettingsArea.tsx b/src/settings/SettingsArea.tsx index af8bf34b3..eaf609d3f 100644 --- a/src/settings/SettingsArea.tsx +++ b/src/settings/SettingsArea.tsx @@ -71,7 +71,11 @@ const SettingsArea = () => { "parameter-help", intl, { - shortcut: (isMac ? "Cmd" : "Ctrl") + "+Shift+Space", + shortcut: intl.formatMessage({ + id: isMac + ? "parameter-help-shortcut-mac" + : "parameter-help-shortcut", + }), } ), }; From a2886bcc4ba7073d22a7389cd02a4caedf79f008 Mon Sep 17 00:00:00 2001 From: helloigig Date: Wed, 4 Nov 2026 11:12:05 +0000 Subject: [PATCH 2/2] Remove parameter help shortcut translation test --- src/settings/SettingsArea.test.tsx | 52 ------------------------------ 1 file changed, 52 deletions(-) delete mode 100644 src/settings/SettingsArea.test.tsx diff --git a/src/settings/SettingsArea.test.tsx b/src/settings/SettingsArea.test.tsx deleted file mode 100644 index e3ee9e4a2..000000000 --- a/src/settings/SettingsArea.test.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/** - * (c) 2026, Micro:bit Educational Foundation and contributors - * - * SPDX-License-Identifier: MIT - */ -import { render, screen } from "@testing-library/react"; -import { IntlProvider } from "react-intl"; -import { vi } from "vitest"; -import en from "../messages/ui.en.json"; -import SettingsArea from "./SettingsArea"; -import SettingsProvider from "./settings"; - -const renderSettingsArea = (messages: Record) => - render( - - - - - - ); - -describe("SettingsArea", () => { - afterEach(() => { - vi.unstubAllGlobals(); - }); - - it("uses the translated parameter help shortcut", () => { - vi.stubGlobal("navigator", { ...navigator, platform: "Win32" }); - renderSettingsArea({ - "parameter-help-manual": "Anleitung ({shortcut})", - "parameter-help-shortcut": "Strg+Umschalt+Leertaste", - }); - expect( - screen.getByRole("option", { - name: "Anleitung (Strg+Umschalt+Leertaste)", - }) - ).toBeDefined(); - }); - - it("uses the translated Mac parameter help shortcut on a Mac", () => { - vi.stubGlobal("navigator", { ...navigator, platform: "MacIntel" }); - renderSettingsArea({ - "parameter-help-manual": "Anleitung ({shortcut})", - "parameter-help-shortcut-mac": "Befehl+Umschalt+Leertaste", - }); - expect( - screen.getByRole("option", { - name: "Anleitung (Befehl+Umschalt+Leertaste)", - }) - ).toBeDefined(); - }); -});