From dc141fc31a875252e8d3d546e9fa8ed687d8dfe7 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Sat, 31 Oct 2026 22:43:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20pack-editor=20i18n=20=E2=80=94=20{n?= =?UTF-8?q?eed}=20placeholder=20in=20en=20p1,=20keep=20base-option=20keys?= =?UTF-8?q?=20visible=20to=20the=20#1024=20dead-key=20guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The guided pack editor (#5345) broke the i18n parity tests on master push CI: 1) en cfg.q_pack_ai_p1 was missing the {need} placeholder its zh twin has (client.ts interpolates t("cfg.q_pack_ai_p1", { need })). 2) Four catalog keys were passed as bare strings through helper parameters (option array / packSectionField), which the #1024 reference scanner (literal t(\"key\") only) cannot see — flagged as dead keys. Labels are now translated at the call sites so every key has a scannable literal reference. Verified locally at origin/master (44fcbe47): tests/web-i18n.test.ts + web-user-packs.test.ts 11/11 (was 9/11); all web/pack/i18n suites 257/257; tsc --noEmit clean. --- src/web/client.ts | 19 +++++++++++-------- src/web/i18n.ts | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/web/client.ts b/src/web/client.ts index 2ad50f2c2f..14bdfcc081 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -4126,10 +4126,13 @@ if (d.keepalive) kv(parts, t("det.keepalive"), d.keepalive.tierLabel + " · " + const baseSel = document.createElement("select"); baseSel.id = "pack-base-sel"; baseSel.className = "field-input"; - [["", "cfg.q_pack_base_blank"], ["default", "cfg.q_pack_base_default"], ["chat", "cfg.q_pack_base_chat"], ["lean", "cfg.q_pack_base_lean"]].forEach((pair) => { + // #5345 follow-up: keep labels as literal t("…") calls — the #1024 + // dead-key guard only counts string-literal arguments, so the old + // array + variable-lookup shape hid all four keys (CI red on master). + [["", t("cfg.q_pack_base_blank")], ["default", t("cfg.q_pack_base_default")], ["chat", t("cfg.q_pack_base_chat")], ["lean", t("cfg.q_pack_base_lean")]].forEach(([value, label]) => { const opt = document.createElement("option"); - opt.value = pair[0]; - opt.textContent = t(pair[1]); + opt.value = value; + opt.textContent = label; baseSel.appendChild(opt); }); const btnBaseLoad = document.createElement("button"); @@ -4148,14 +4151,14 @@ if (d.keepalive) kv(parts, t("det.keepalive"), d.keepalive.tierLabel + " · " + descIn.placeholder = t("cfg.q_pack_desc_ph"); descIn.style.cssText = "width:100%;box-sizing:border-box"; descWrap.append(descLab, descIn); - function packSectionField(labelKey, helpKey, rows) { + function packSectionField(label, helpText, rows) { const wrap = document.createElement("div"); wrap.style.cssText = "margin:8px 0"; const lab = document.createElement("div"); - lab.textContent = t(labelKey); + lab.textContent = label; lab.style.cssText = "font-size:13px;font-weight:600;margin-bottom:2px"; const help = document.createElement("div"); - help.textContent = t(helpKey); + help.textContent = helpText; help.style.cssText = "font-size:12px;color:#57606a;margin-bottom:4px"; const ta = document.createElement("textarea"); ta.className = "field-input mono"; @@ -4165,8 +4168,8 @@ if (d.keepalive) kv(parts, t("det.keepalive"), d.keepalive.tierLabel + " · " + wrap.append(lab, help, ta); return { wrap, ta }; } - const phF = packSectionField("cfg.q_pack_phil", "cfg.q_pack_phil_help", 5); - const hcF = packSectionField("cfg.q_pack_hc", "cfg.q_pack_hc_help", 8); + const phF = packSectionField(t("cfg.q_pack_phil"), t("cfg.q_pack_phil_help"), 5); + const hcF = packSectionField(t("cfg.q_pack_hc"), t("cfg.q_pack_hc_help"), 8); const taPh = phF.ta; const taHc = hcF.ta; const formHint = document.createElement("div"); diff --git a/src/web/i18n.ts b/src/web/i18n.ts index 8024e28b5a..078ff64c90 100644 --- a/src/web/i18n.ts +++ b/src/web/i18n.ts @@ -1353,7 +1353,7 @@ export const MESSAGES: Record> = { "cfg.q_pack_ai_apply_ok": "Parsed and filled into the form; the full JSON is synced to the Advanced (JSON) tab", "cfg.q_pack_ai_extra": "The model also returned advanced fields: {names} — kept in the Advanced (JSON) tab and saved with the pack", "cfg.q_pack_json_obj": "the pasted content must be a single JSON object", - "cfg.q_pack_ai_p1": "You are helping me customize a compression prompt pack for billion-context. My scenario and requirements:", + "cfg.q_pack_ai_p1": "You are helping me customize a compression prompt pack for billion-context. My scenario and requirements are as follows: {need}", "cfg.q_pack_ai_p2": "Write the JSON in bili-pack.json shape. Top-level object may contain: name (optional; lowercase letters/digits and ._- ; omit if unwanted), description (optional; one plain-sentence purpose), promptSections (object; at least one of): philosophy — the stance summaries take, what to keep first, what must never be lost; howToCompress — concrete summary-writing rules: structure, granularity, timeline requirements.", "cfg.q_pack_ai_p3": "Rules: 1. Content must fit my concrete scenario — no generic filler; 2. The readers of both sections are the AI model itself — clear imperative bullet-style sentences; 3. If a section adds no value for my scenario, OMIT that key entirely (omitted = system defaults stay) instead of writing an empty string; 4. Output ONLY one JSON object — no markdown fences, no comments, no prose.", "cfg.q_pck": "prompt_cache_key self-stamping (promptCache.routing)",