fix(i18n): numbers, units, dates and order in the UI language, and after a switch (E30 S3)
Every locale formatter takes the language as an argument. Under the React
Compiler a formatter that read the i18n singleton was memoized on its other
arguments, so a card kept "2 hr 4 min" after a switch to Hungarian; plexLang()
had the same flaw and left Plex queries in the old language. Components now
take the language from useTranslation, and the signature makes forgetting it
a type error.
- ratings, file sizes, stream stats: the language's decimal mark ("8,3")
- view and subscriber counts compact in the language ("1,2 E")
- seconds as the language's unit ("6 mp") in the sliders and the stats
- a person's birth and death dates as dates, not ISO strings
- A-Z lists by the shown name in the language's alphabet (compareText),
the tag catalog re-sorted by its translated names
- lint local/locale-format (was date-format) also refuses Intl.NumberFormat
outside lib/format.ts, localeCompare, and a component reading the language
off the i18n singleton
This commit is contained in:
@@ -12,12 +12,16 @@ describe("a job's result", () => {
|
||||
it("names each count, and a phase's own counts inside it", () => {
|
||||
setLanguage("hu");
|
||||
const t = i18n.getFixedT("hu");
|
||||
expect(jobResultText(t, { new: 3, failed: 0 })).toBe("új videó: 3 · sikertelen: 0");
|
||||
expect(jobResultText(t, { new: 3, failed: 0 }, "hu")).toBe("új videó: 3 · sikertelen: 0");
|
||||
expect(
|
||||
jobResultText(t, {
|
||||
recent: { channels_processed: 0, videos_added: 0, reason: "no service user" },
|
||||
deep: { channels_processed: 2, videos_added: 5, reconciled_full: 1 },
|
||||
}),
|
||||
jobResultText(
|
||||
t,
|
||||
{
|
||||
recent: { channels_processed: 0, videos_added: 0, reason: "no service user" },
|
||||
deep: { channels_processed: 2, videos_added: 5, reconciled_full: 1 },
|
||||
},
|
||||
"hu",
|
||||
),
|
||||
).toBe(
|
||||
"friss (feldolgozott csatorna: 0 · hozzáadott videó: 0 · ok: nincs szolgáltatásfiók) · " +
|
||||
"mély (feldolgozott csatorna: 2 · hozzáadott videó: 5 · teljesen egyeztetve: 1)",
|
||||
@@ -26,15 +30,15 @@ describe("a job's result", () => {
|
||||
|
||||
it("names a skip reason; an upstream error stays its own text", () => {
|
||||
const t = i18n.getFixedT("hu");
|
||||
expect(jobResultText(t, { enriched: 0, skipped: "tmdb_api_key not set" })).toBe(
|
||||
expect(jobResultText(t, { enriched: 0, skipped: "tmdb_api_key not set" }, "hu")).toBe(
|
||||
"kiegészítve: 0 · kihagyva: nincs TMDB API-kulcs",
|
||||
);
|
||||
expect(jobResultText(t, { error: "Plex returned 500" })).toBe("hiba: Plex returned 500");
|
||||
expect(jobResultText(t, { error: "Plex returned 500" }, "hu")).toBe("hiba: Plex returned 500");
|
||||
});
|
||||
|
||||
it("shows a key or word it does not know as it is, readable", () => {
|
||||
const t = i18n.getFixedT("hu");
|
||||
expect(jobResultText(t, { brand_new_count: 3, skipped: "moon is full" })).toBe(
|
||||
expect(jobResultText(t, { brand_new_count: 3, skipped: "moon is full" }, "hu")).toBe(
|
||||
"brand new count: 3 · kihagyva: moon is full",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user