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.
This commit is contained in:
yetone
2026-10-24 17:04:32 +08:00
parent 616c87256a
commit 2027381acf
2 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -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))))) {
+25
View File
@@ -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, []);
});