Choose the best post translation
Choose the highest-quality translation by locale fallback order, freshness, and stable translation ID.Description
Requirements
Export choosePostTranslation from src/App.js.
Compare locale tags case-insensitively with underscores normalized to hyphens.
Prefer exact requested locale, then its base language, then input.defaultLocale.
Within one locale prefer higher quality and then greater updatedAt.
Break remaining ties by ascending translation ID and return null when no candidate locale matches.
Return an observably equivalent result for equivalent inputs without reading time, randomness, network, storage, or DOM globals.
Do not mutate input objects, arrays, nested records, or values retained in the returned result.
Regional fallback
Requested fr-CA with only fr and en
The best fr translation is selected
Compare locale tags case-insensitively with underscores normalized to hyphens.
Quality tie
Two en translations share quality
The newer translation wins
Prefer exact requested locale, then its base language, then input.defaultLocale.
Constraints
Implement a pure synchronous function with no external side effectsTreat every input collection and nested record as read-onlyReturn JSON-compatible data except where the declared TypeScript API explicitly uses bigint
Hints
Hint 1
Start with the normalizes-locales behavior and make its observable result deterministic.
Hint 2
Model uses-fallback-order independently before combining it with the remaining states.
Hint 3
Verify the boundary described by stable-id-tie-break without changing caller-owned input.