feat(i18n): the server's closed English vocabularies named in the reader's language (E30 S2)

- lib/vocab + the `vocab` locale area: TMDB crew jobs and departments, auto-tags (D1 A: the data
  stays English, the catalog is named at its one source, useTags), built-in download profiles,
  YouTube topics; held key-for-key to the backend's own lists by backendIds.contract.
- Countries by ISO code: TMDB parse stores {code, name}; rows stored before are coded from TMDB's
  own country list in one request (run_enrich); Intl names them, historic codes (YU, SU, XI…)
  from the catalog.
- Player tracks named from the language tag, forced/SDH flags and codec tail, not Plex's
  server-language displayTitle; no invented "Audio N" on the server.
- Download lifecycle notices (shared / expiring / expired / evicted) named from data; the share
  notice carries the title.
- Scheduler: the job result rides along as data and is named per key (dashboard + run notice).
- Invite status named; a render crash's notice no longer shows the engine's English message.
- Fix: YouTube links …/wiki/Humour, the tagger looked for "Humor" — Comedy never came from a topic.
This commit is contained in:
2026-09-29 21:21:19 +02:00
parent f6298d29af
commit f3a85916ec
50 changed files with 1475 additions and 94 deletions
+115
View File
@@ -0,0 +1,115 @@
// @vitest-environment jsdom
//
// E30: the server's closed English vocabularies, named in the reader's language — through the REAL
// catalog, so a missing or misnamed key shows here as the English word coming through.
import { describe, expect, it } from "vitest";
import i18n from "../i18n";
import { languageName, profileName, regionName, trackLabel, vocab } from "./vocab";
const hu = i18n.getFixedT("hu");
const en = i18n.getFixedT("en");
describe("a vocabulary word", () => {
it.each([
["crewJob", "Director of Photography", "Operatőr"],
["crewJob", "Executive Producer", "Vezető producer"],
["department", "Acting", "Színészet"],
["autoTag", "Health & Fitness", "Egészség és fitnesz"],
["autoTag", "Hungarian", "Magyar"],
["profile", "Video only (MP4)", "Csak videó (MP4)"],
["topic", "Lifestyle_(sociology)", "Életmód"],
] as const)("%s %j reads %j in Hungarian", (group, word, shown) => {
expect(vocab(hu, group, word)).toBe(shown);
});
it("the English reader sees the word as it was", () => {
expect(vocab(en, "crewJob", "Director of Photography")).toBe("Director of Photography");
expect(vocab(en, "topic", "Pop_music", "Pop music")).toBe("Pop music");
});
it("an unknown word is shown, not hidden or keyed", () => {
expect(vocab(hu, "crewJob", "Gaffer")).toBe("Gaffer");
expect(vocab(hu, "topic", "Knitting_(craft)", "Knitting (craft)")).toBe("Knitting (craft)");
});
});
describe("a country", () => {
it("is named from its code in the reader's language", () => {
expect(regionName(hu, "US", "hu", "United States of America")).toBe("Egyesült Államok");
expect(regionName(en, "DE", "en", "Germany")).toBe("Germany");
});
it("that no longer exists keeps its own name — Intl would call Yugoslavia Serbia", () => {
expect(regionName(hu, "YU", "hu", "Yugoslavia")).toBe("Jugoszlávia");
expect(regionName(hu, "SU", "hu", "Soviet Union")).toBe("Szovjetunió");
expect(regionName(en, "XI", "en", "Northern Ireland")).toBe("Northern Ireland");
});
it("without a code shows the stored name", () => {
expect(regionName(hu, null, "hu", "Hungary")).toBe("Hungary");
});
});
describe("a language", () => {
it("stands alone capitalized, region kept", () => {
expect(languageName("hu", "hu")).toBe("Magyar");
expect(languageName("en-US", "en")).toBe("American English");
});
it("falls back to what was given for a tag Intl cannot name", () => {
expect(languageName("qqq", "hu", "Klingon")).toBe("Klingon");
expect(languageName("und", "hu", "Unknown")).toBe("Unknown"); // "undetermined": no language
});
});
describe("a player track", () => {
const track = { ord: 0, label: "English (AC3 5.1)", lang_tag: "en-US", detail: "AC3 5.1" };
it("is named from its language, not Plex's server-language title", () => {
expect(trackLabel(hu, track, "audio", "hu")).toBe("Angol (AC3 5.1)");
expect(trackLabel(en, track, "audio", "en")).toBe("English (AC3 5.1)");
});
it("says forced / SDH and translates the channel word", () => {
expect(
trackLabel(
hu,
{ ord: 1, label: "magyar Forced", lang_tag: "hu", forced: true },
"subtitle",
"hu",
),
).toBe("Magyar, kényszerített");
expect(
trackLabel(
hu,
{ ord: 2, label: "中文", lang_tag: "zh", detail: "EAC3 Stereo" },
"audio",
"hu",
),
).toBe("Kínai (EAC3 sztereó)");
expect(
trackLabel(
en,
{ ord: 3, label: "English SDH", lang_tag: "en", hearing_impaired: true },
"subtitle",
"en",
),
).toBe("English, SDH");
});
it("with no language keeps Plex's title, and with nothing is numbered", () => {
expect(trackLabel(hu, { ord: 0, label: "Commentary" }, "audio", "hu")).toBe("Commentary");
expect(trackLabel(hu, { ord: 2, label: null, lang_tag: "und" }, "audio", "hu")).toBe(
"3. hangsáv",
);
expect(trackLabel(hu, { ord: 1, label: null }, "subtitle", "hu")).toBe("2. felirat");
expect(trackLabel(en, { ord: 0, label: null }, "audio", "en")).toBe("Audio 1");
});
});
describe("a download profile", () => {
it("built in, is named in the reader's language; the user's own stays as typed", () => {
expect(profileName(hu, { name: "Audio (MP3)", is_builtin: true })).toBe("Hang (MP3)");
expect(profileName(hu, { name: "Audio (MP3)", is_builtin: false })).toBe("Audio (MP3)");
});
});