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:
@@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, Circle, Info, ListPlus, Star } from "lucide-react";
|
||||
import clsx from "clsx";
|
||||
import { type ReactNode, useRef } from "react";
|
||||
import { formatRuntime } from "../lib/format";
|
||||
import { formatDecimal, formatRuntime } from "../lib/format";
|
||||
import { Carousel } from "./ui/Carousel";
|
||||
import type { PlexCard, PlexCastMember, PlexFilters, PlexSeasonDetail } from "../lib/api";
|
||||
import { seasonTitle } from "../lib/plexDetail";
|
||||
@@ -287,7 +287,8 @@ export function PlexPosterCard({
|
||||
/** The show's page, beside a `next` episode. */
|
||||
onInfo?: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = i18n.language;
|
||||
const preview = useMediaPreview();
|
||||
// An episode in a poster rail (Discover's "Recently watched") stands as its SHOW: the show's poster
|
||||
// and name, the episode on the line under it (E30, option A). Its own 16:9 still in a poster slot
|
||||
@@ -302,7 +303,7 @@ export function PlexPosterCard({
|
||||
const acted = ep ?? card;
|
||||
const watched = card.status === "watched";
|
||||
const actedWatched = acted.status === "watched";
|
||||
const runtime = formatRuntime(card.duration_seconds);
|
||||
const runtime = formatRuntime(card.duration_seconds, lang);
|
||||
const pct = ep ? progressPct(ep) : watched ? 0 : progressPct(card);
|
||||
const m = more(card, menuButtonProps, menuOpen);
|
||||
const toggle = isPlayable && onToggleWatched ? () => onToggleWatched(acted) : undefined;
|
||||
@@ -317,7 +318,7 @@ export function PlexPosterCard({
|
||||
const rating = card.rating != null && (
|
||||
<span className="inline-flex items-center gap-0.5">
|
||||
<Star className="w-3 h-3 fill-current text-rating" aria-hidden />
|
||||
{card.rating.toFixed(1)}
|
||||
{formatDecimal(card.rating, lang)}
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
@@ -649,11 +650,12 @@ export function EpisodeCard({
|
||||
menuOpen?: boolean;
|
||||
navIndex?: number;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = i18n.language;
|
||||
const watched = ep.status === "watched";
|
||||
const pct = watched ? 0 : progressPct(ep);
|
||||
const m = more(ep, menuButtonProps, menuOpen);
|
||||
const runtime = formatRuntime(ep.duration_seconds);
|
||||
const runtime = formatRuntime(ep.duration_seconds, lang);
|
||||
return (
|
||||
<MediaCard
|
||||
dense
|
||||
|
||||
Reference in New Issue
Block a user