whitelist valid dynamic translation

This commit is contained in:
Timothy Carambat 2026-03-24 08:24:05 -07:00
parent a2ae761f1a
commit 8937b8a98b
2 changed files with 24 additions and 20 deletions

View File

@ -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;

View File

@ -10,7 +10,30 @@ import fs from "fs";
import path from "path"; import path from "path";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
import { resources } from "./resources.js"; 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 __dirname = path.dirname(fileURLToPath(import.meta.url));
const FRONTEND_SRC = path.resolve(__dirname, ".."); const FRONTEND_SRC = path.resolve(__dirname, "..");