Skip to content

fix(tmdb): drive release/cert/provider region priority from locale, not a hardcoded FR list - #96

Open
ndandan wants to merge 3 commits into
Shoshuo:mainfrom
ndandan:pr/tmdb-region-priority
Open

fix(tmdb): drive release/cert/provider region priority from locale, not a hardcoded FR list#96
ndandan wants to merge 3 commits into
Shoshuo:mainfrom
ndandan:pr/tmdb-region-priority

Conversation

@ndandan

@ndandan ndandan commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

The Discover / quick-look TMDb lookups picked release dates, content certifications, alternative titles and streaming providers from a hardcoded FR-first country list (e.g. ['FR', 'BE', 'LU', 'US', 'GB'], ['FR', 'US']). An English-locale install therefore saw French theatrical dates, French ratings and French provider availability instead of its own region's.

Region priority is now derived from the active locale:

  • New TmdbClient::regionPriority(string $locale, array $append = []) returns a country-code priority list led by the locale's home region (en → US/GB/CA/AU, fr → FR/BE/LU/CA, plus es/de/pt/it), followed by a broad common fallback chain and any extra countries actually present in the payload — de-duplicated and order-preserving.
  • Wired at all six lookup sites via $this->translator->getLocale(): TmdbController alt-titles / providers / movie-certification / tv-certification, and DashboardController movie release-dates / quick-look providers.
  • Unit test TmdbClientRegionPriorityTest covers 6 cases (fr/en lead, locale suffix, append dedup, unknown + empty locale fallbacks).

Behaviour for FR installs is unchanged (FR still leads for fr locale); non-FR installs now get their own region's data.

ndandan and others added 2 commits August 21, 2026 21:41
…#2)

Design-critique deferred item. TMDb release dates, certifications, alt
titles and watch/providers all picked countries from hardcoded FR-first
lists, so an English user saw French release dates and providers first.

- New TmdbClient::regionPriority(locale, append) returns a country-code
  priority led by the locale's home region (en → US/GB/CA/AU, fr →
  FR/BE/LU/CA, + es/de/pt/it), followed by a broad common fallback chain
  and any extra countries present in the payload, de-duplicated and
  order-preserving.
- Wired at all six sites (via $this->translator->getLocale()):
  TmdbController alt-titles / pickProviders / pickMovieCertification /
  pickTvCertification, DashboardController tmdbMovieReleaseDates /
  quick-look providers.
- Unit test for regionPriority (6 cases: fr/en lead, locale suffix,
  append dedup, unknown + empty locale fallbacks) — green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ndandan ndandan changed the title pr/tmdb region priority fix(tmdb): drive release/cert/provider region priority from locale, not a hardcoded FR list Aug 22, 2026
…code to a country

Two regionPriority() fixes:

- An explicit region subtag now leads the chain outright: en_GB users get
  GB-first (previously the 'en' language map still led with US), fr-CA
  leads CA, pt_BR leads BR.
- The default arm no longer fabricates a country from the language code.
  'sv' is Swedish but 'SV' is El Salvador — an unmapped language upcast
  that way would rank the wrong country's certifications/providers first
  ('ja'->JA, 'ko'->KO, 'uk'->UK are invalid or wrong codes). Unmapped
  languages now fall straight to the common chain + payload countries.

Latent today (enabled_locales is en+fr, both mapped) but the method is a
public static API; regression tests added for both behaviors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant