From af24899ac5add6c0f6a35609aeaef3dad3e84491 Mon Sep 17 00:00:00 2001 From: danny Date: Sat, 31 Oct 2026 14:55:15 +0100 Subject: [PATCH] A3: singular and plural counts in the Problems window The summary and the per-file count tooltip pick one/other catalog messages ("1 error", "3 errors") instead of the plural-free wording. Co-Authored-By: Claude Opus 5.5 --- .../problems/ProblemsToolWindow.vue | 22 +++++++++++++++---- ui/src/i18n/en.json | 10 +++++++-- ui/tests/problems/ProblemsToolWindow.test.ts | 10 ++++++++- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ui/src/components/problems/ProblemsToolWindow.vue b/ui/src/components/problems/ProblemsToolWindow.vue index 2d58da2..6803403 100644 --- a/ui/src/components/problems/ProblemsToolWindow.vue +++ b/ui/src/components/problems/ProblemsToolWindow.vue @@ -68,13 +68,27 @@ const status = computed(() => { return t("problems.empty"); } const c = problems.counts; + const others = c.info + c.hint; return t("problems.summary", { - errors: String(c.error), - warnings: String(c.warning), - infos: String(c.info + c.hint), + errors: + c.error === 1 ? t("problems.count.error.one") : t("problems.count.error.other", { count: String(c.error) }), + warnings: + c.warning === 1 + ? t("problems.count.warning.one") + : t("problems.count.warning.other", { count: String(c.warning) }), + infos: t("problems.count.other", { count: String(others) }), }); }); +/** + * The tooltip of a file's problem count, singular for one. + * + * @param count - the file's problems. + */ +function fileCountTitle(count: number): string { + return count === 1 ? t("problems.file.count.one") : t("problems.file.count.other", { count: String(count) }); +} + /** A file with its rows and their indexes in the flat list. */ interface ProblemGroup { /** Project-relative path. */ @@ -238,7 +252,7 @@ watch( {{ dirName(group.path) }} {{ group.rows.length }}
{ items: [diag(4, "warning", "Unused variable"), { ...diag(1, "error", "Undefined method"), code: "E12" }], }); await emit({ kind: "diagnosticsChanged", path: "a.php", items: [diag(0, "hint", "Could be final")] }); - expect(wrapper.get("[data-test=problems-status]").text()).toBe("Errors: 1, warnings: 1, other: 1"); + expect(wrapper.get("[data-test=problems-status]").text()).toBe("1 error, 1 warning, 1 other"); + expect(wrapper.findAll(".problems__file-count").map((c) => c.attributes("title"))).toEqual(["1 problem", "2 problems"]); + await emit({ + kind: "diagnosticsChanged", + path: "b.php", + items: [diag(0, "error", "One"), diag(1, "error", "Two")], + }); + expect(wrapper.get("[data-test=problems-status]").text()).toBe("3 errors, 1 warning, 1 other"); + await emit({ kind: "diagnosticsChanged", path: "b.php", items: [] }); const files = wrapper.findAll("[data-test=problems-file]").map((f) => f.text()); expect(files[0]).toContain("a.php"); expect(files[1]).toContain("Service.php");