From 8937b8a98b77390c548bf7d09803e2544a4438ce Mon Sep 17 00:00:00 2001 From: Timothy Carambat Date: Tue, 24 Mar 2026 08:24:05 -0700 Subject: [PATCH] whitelist valid dynamic translation --- frontend/src/locales/dynamicKeyAllowlist.js | 19 -------------- .../src/locales/findUnusedTranslations.mjs | 25 ++++++++++++++++++- 2 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 frontend/src/locales/dynamicKeyAllowlist.js diff --git a/frontend/src/locales/dynamicKeyAllowlist.js b/frontend/src/locales/dynamicKeyAllowlist.js deleted file mode 100644 index 75243556..00000000 --- a/frontend/src/locales/dynamicKeyAllowlist.js +++ /dev/null @@ -1,19 +0,0 @@ -// Keys listed here are used dynamically (e.g. t(variable)) and should never -// be flagged as unused or deleted by findUnusedTranslations.mjs. -// -// When you add a dynamic t() call, add the affected key(s) here so the -// pruning script knows they are intentionally referenced at runtime. -const DYNAMIC_KEY_ALLOWLIST = [ - // Used dynamically in KeyboardShortcutsHelp via t(`keyboard-shortcuts.shortcuts.${shortcut.translationKey}`) - "keyboard-shortcuts.shortcuts.settings", - "keyboard-shortcuts.shortcuts.home", - "keyboard-shortcuts.shortcuts.workspaces", - "keyboard-shortcuts.shortcuts.apiKeys", - "keyboard-shortcuts.shortcuts.llmPreferences", - "keyboard-shortcuts.shortcuts.chatSettings", - "keyboard-shortcuts.shortcuts.help", - "keyboard-shortcuts.shortcuts.showLLMSelector", - "keyboard-shortcuts.shortcuts.workspaceSettings", -]; - -export default DYNAMIC_KEY_ALLOWLIST; diff --git a/frontend/src/locales/findUnusedTranslations.mjs b/frontend/src/locales/findUnusedTranslations.mjs index 9f5a45ea..6f560fce 100644 --- a/frontend/src/locales/findUnusedTranslations.mjs +++ b/frontend/src/locales/findUnusedTranslations.mjs @@ -10,7 +10,30 @@ import fs from "fs"; import path from "path"; import { fileURLToPath } from "url"; import { resources } from "./resources.js"; -import DYNAMIC_KEY_ALLOWLIST from "./dynamicKeyAllowlist.js"; + +/** + * @type {string[]} + * Keys listed here are used dynamically (e.g. t(variable)) and should never + * be flagged as unused or deleted by findUnusedTranslations.mjs. + * When you add a dynamic t() call, add the affected key(s) here so the + * pruning script knows they are intentionally referenced at runtime. + */ +const DYNAMIC_KEY_ALLOWLIST = [ + "keyboard-shortcuts.shortcuts.settings", + "keyboard-shortcuts.shortcuts.home", + "keyboard-shortcuts.shortcuts.workspaces", + "keyboard-shortcuts.shortcuts.apiKeys", + "keyboard-shortcuts.shortcuts.llmPreferences", + "keyboard-shortcuts.shortcuts.chatSettings", + "keyboard-shortcuts.shortcuts.help", + "keyboard-shortcuts.shortcuts.showLLMSelector", + "keyboard-shortcuts.shortcuts.workspaceSettings", + + // Used for chat mode descriptions + "chat.mode.automatic.description", + "chat.mode.chat.description", + "chat.mode.query.description", +]; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const FRONTEND_SRC = path.resolve(__dirname, "..");