fix(notifications): the English log formats its numbers in English; the ui/ contract sees msg() keys

A formatted value took the reader's language even when the notice was said in English for the
log. The platform-namespace contract matched only t("…"), so a domain key passed through msg()
in components/ui/ went unseen. Three comments pointed at localizeDetail's old home.
This commit is contained in:
2026-10-30 00:15:22 +01:00
parent b515c16117
commit 74f58ea001
6 changed files with 34 additions and 8 deletions
@@ -7,7 +7,8 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, render } from "@testing-library/react";
import { clear, events } from "../lib/log";
import { notify, raw } from "../lib/notifications";
import { msg, notify, raw } from "../lib/notifications";
import i18n from "../i18n";
import { reportError } from "../lib/errorDialog";
import { createQueryClient } from "../lib/queryClient";
import ErrorBoundary from "./ErrorBoundary";
@@ -31,6 +32,27 @@ describe("client log wiring", () => {
]);
});
it("records a notice in English whatever the reader's language, its numbers included", async () => {
await i18n.changeLanguage("hu");
try {
notify({
message: msg("settings.takeout.read", {
name: raw("watch-history.json"),
count: 12345,
n: { number: 12345 },
}),
});
} finally {
await i18n.changeLanguage("en");
}
const english = i18n.getFixedT("en")("settings.takeout.read", {
name: "watch-history.json",
count: 12345,
n: "12,345",
});
expect(logged("ui.notify").map((e) => e.msg)).toEqual([english]);
});
it("records the blocking error dialog", () => {
reportError("The server refused", "Couldn't save");
expect(logged("ui.error_dialog")).toMatchObject([