From 2027381acf501b2767390a45639dbe9155b6a296 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 24 Oct 2026 17:04:29 +0800 Subject: [PATCH] gui: Usage's empty Sessions text is translated again (Outvi V on Discord) Usage's Sessions tab, with no sessions on this computer, said "No sessions yet. Claude Code's, Codex's, OpenCode's and Pi's sessions..." in English in every language. 5a4104632 (#569) added Hermes to that text's key in i18n.js, and the page kept the old wording, which has no key. The page now says the key's text, Hermes included (Hermes sessions are listed there). i18n-keys gains "every word the window says has a key": every t("...") literal in assets' scripts must have a zh key, "magpie" and "ID" excepted as English on purpose. This was the only one missing. Run: node --test internal/gui/tests/i18n-keys.test.cjs, 4 of 4 pass; with the old page.js the new test fails naming page.js:2532. No other test or source names the old wording. Not tried: the window itself in each language. --- internal/gui/assets/plugins/usage/page.js | 2 +- internal/gui/tests/i18n-keys.test.cjs | 25 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/internal/gui/assets/plugins/usage/page.js b/internal/gui/assets/plugins/usage/page.js index e068fbe53..bcc182bbd 100644 --- a/internal/gui/assets/plugins/usage/page.js +++ b/internal/gui/assets/plugins/usage/page.js @@ -2529,7 +2529,7 @@ function renderSessions() { stats.classList.remove("six"); stats.classList.add("empty"); const filtered = sessAgent !== "all" || sessModel || sessFolder || q; - stats.append(el("div", "none", !all.length && !rows.length ? t("No sessions yet. Claude Code's, Codex's, OpenCode's and Pi's sessions on this computer show up here, with what each cost and the command that resumes it.") : filtered ? t("No session matches.") : t("Nothing in this range."))); + stats.append(el("div", "none", !all.length && !rows.length ? t("No sessions yet. Claude Code's, Codex's, Hermes, OpenCode's and Pi's sessions on this computer show up here, with what each cost and the command that resumes it.") : filtered ? t("No session matches.") : t("Nothing in this range."))); if (from && all.some((s) => byAgent(s) && byFolder(s) && (!sessModel || s.models.some((m) => m.model === sessModel)) && (!q || [s.title, s.cwd, s.id, s.name, ...s.models.map((m) => m.model)].some((x) => (x || "").toLowerCase().includes(q))))) { diff --git a/internal/gui/tests/i18n-keys.test.cjs b/internal/gui/tests/i18n-keys.test.cjs index af0f2f69d..ed21b1bb4 100644 --- a/internal/gui/tests/i18n-keys.test.cjs +++ b/internal/gui/tests/i18n-keys.test.cjs @@ -61,3 +61,28 @@ test("a plugin's words are its own", () => { } assert.deepEqual(shared, []); }); + +test("every word the window says has a key", () => { + // Usage's empty Sessions text kept "Codex's, OpenCode's" after i18n.js's + // key gained Hermes, so it showed in English in every language (Outvi V) + const fs = require("node:fs"), path = require("node:path"); + const { zh } = strings().I18N; + const assets = path.resolve(__dirname, "../assets"), files = []; + const walk = (d) => { + for (const e of fs.readdirSync(d, { withFileTypes: true })) { + const p = path.join(d, e.name); + if (e.isDirectory()) walk(p); + else if (e.name.endsWith(".js") && e.name !== "i18n.js") files.push(p); + } + }; + walk(assets); + const english = new Set(["magpie", "ID"]), missing = []; + for (const f of files) { + const src = fs.readFileSync(f, "utf8"), re = /\bt\(\s*"((?:[^"\\]|\\.)*)"\s*[,)]/g; + for (let m; (m = re.exec(src)); ) { + const k = JSON.parse(`"${m[1]}"`); + if (!(k in zh) && !english.has(k)) missing.push(`${path.relative(assets, f)}:${src.slice(0, m.index).split("\n").length} ${JSON.stringify(k)}`); + } + } + assert.deepEqual(missing, []); +});