Skip to content

Commit 40d03af

Browse files
committed
fix(cep): make command palette section labels and descriptions i18n-ready
Section labels ("Recent", "Favorites", "Matching Tools", etc.) and tab fallback descriptions are now configurable via sectionLabels and descriptionMap options passed to makePaletteContext(). Callers can inject translated strings from t(); defaults remain the existing English text for backward compatibility.
1 parent a2cb353 commit 40d03af

1 file changed

Lines changed: 32 additions & 26 deletions

File tree

extension/com.opencut.panel/client/panel-utils.js

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,40 @@
5757
return [item.name || "", item.tab || "", item.sub || ""].join("::");
5858
}
5959

60+
var DEFAULT_TAB_DESCRIPTIONS = {
61+
cut: "Tighten pacing, trims, and spoken edits from one focused cut workflow.",
62+
captions: "Transcribe, translate, and shape subtitle deliverables without leaving the panel.",
63+
audio: "Polish dialogue, stems, loudness, and generated sound from one audio surface.",
64+
video: "Repair, reframe, and finish image work with cleaner visual controls.",
65+
export: "Build deliverables, thumbnails, and repeatable output presets faster.",
66+
timeline: "Write sequence edits and timeline metadata back into Premiere with more control.",
67+
nlp: "Use search and language-driven tools to find footage or trigger edit actions.",
68+
settings: "Adjust workspace defaults, templates, and system-level behavior.",
69+
_default: "Open this tool and jump directly to the matching workspace.",
70+
_none: "Open tools across the editing workflow.",
71+
};
72+
6073
function descriptionForItem(item, descriptionMap) {
6174
var itemKey = getCommandPaletteItemKey(item);
6275
if (descriptionMap && descriptionMap[itemKey]) return descriptionMap[itemKey];
63-
if (!item) return "Open tools across the editing workflow.";
64-
switch (item.tab) {
65-
case "cut":
66-
return "Tighten pacing, trims, and spoken edits from one focused cut workflow.";
67-
case "captions":
68-
return "Transcribe, translate, and shape subtitle deliverables without leaving the panel.";
69-
case "audio":
70-
return "Polish dialogue, stems, loudness, and generated sound from one audio surface.";
71-
case "video":
72-
return "Repair, reframe, and finish image work with cleaner visual controls.";
73-
case "export":
74-
return "Build deliverables, thumbnails, and repeatable output presets faster.";
75-
case "timeline":
76-
return "Write sequence edits and timeline metadata back into Premiere with more control.";
77-
case "nlp":
78-
return "Use search and language-driven tools to find footage or trigger edit actions.";
79-
case "settings":
80-
return "Adjust workspace defaults, templates, and system-level behavior.";
81-
default:
82-
return "Open this tool and jump directly to the matching workspace.";
83-
}
76+
if (!item) return (descriptionMap && descriptionMap._none) || DEFAULT_TAB_DESCRIPTIONS._none;
77+
var tabDescs = (descriptionMap && descriptionMap._tabDescriptions) || DEFAULT_TAB_DESCRIPTIONS;
78+
return tabDescs[item.tab] || tabDescs._default || DEFAULT_TAB_DESCRIPTIONS._default;
8479
}
8580

81+
var DEFAULT_SECTION_LABELS = {
82+
recent: "Recent",
83+
favorites: "Favorites",
84+
currentWorkspace: "Current Workspace",
85+
suggestedTools: "Suggested Tools",
86+
browseAll: "Browse All",
87+
matchingTools: "Matching Tools",
88+
};
89+
8690
function makePaletteContext(options) {
8791
options = options || {};
8892
return {
93+
sectionLabels: options.sectionLabels || DEFAULT_SECTION_LABELS,
8994
items: Array.isArray(options.items) ? options.items : [],
9095
query: normalizePaletteText(options.query),
9196
activeTab: options.activeTab || "",
@@ -227,19 +232,20 @@
227232
return (a.name || "").localeCompare(b.name || "");
228233
});
229234

230-
addPaletteSection(sections, "Recent", recentItems, ctx, function (item) {
235+
var sl = ctx.sectionLabels || DEFAULT_SECTION_LABELS;
236+
addPaletteSection(sections, sl.recent, recentItems, ctx, function (item) {
231237
return { isRecent: true, isCurrent: item.tab === ctx.activeTab };
232238
}, seen);
233239

234-
addPaletteSection(sections, "Favorites", favoriteItems, ctx, function (item, key) {
240+
addPaletteSection(sections, sl.favorites, favoriteItems, ctx, function (item, key) {
235241
return { isRecent: !!historyLookup[key], isCurrent: item.tab === ctx.activeTab };
236242
}, seen);
237243

238-
addPaletteSection(sections, ctx.activeTab ? "Current Workspace" : "Suggested Tools", currentItems, ctx, function (item, key) {
244+
addPaletteSection(sections, ctx.activeTab ? sl.currentWorkspace : sl.suggestedTools, currentItems, ctx, function (item, key) {
239245
return { isRecent: !!historyLookup[key], isCurrent: true };
240246
}, seen);
241247

242-
addPaletteSection(sections, "Browse All", browseItems, ctx, function (item, key) {
248+
addPaletteSection(sections, sl.browseAll, browseItems, ctx, function (item, key) {
243249
return { isRecent: !!historyLookup[key], isCurrent: item.tab === ctx.activeTab };
244250
}, seen);
245251
return sections;
@@ -264,7 +270,7 @@
264270
return (a.item.name || "").localeCompare(b.item.name || "");
265271
});
266272

267-
if (matches.length) sections.push({ label: "Matching Tools", entries: matches });
273+
if (matches.length) sections.push({ label: (ctx.sectionLabels || DEFAULT_SECTION_LABELS).matchingTools, entries: matches });
268274
return sections;
269275
}
270276

0 commit comments

Comments
 (0)