Skip to content

fix(l10n): stop requesting en-US ftl files we never deploy - #21124

Merged
vbudhram merged 1 commit into
mainfrom
fxa-10363
Sep 1, 2026
Merged

fix(l10n): stop requesting en-US ftl files we never deploy#21124
vbudhram merged 1 commit into
mainfrom
fxa-10363

Conversation

@vbudhram

Copy link
Copy Markdown
Contributor

Because

  • supported-languages.json lists en-US, but the l10n repo only ships en, en-CA and en-GB. Every page load asked for .../en-US/main.ftl and got a 404, so the request could never be a cache hit.
  • Negotiation made that unavoidable. en-US matched itself, and a plain en header expanded to every en-* entry in the list, which pulled en-US in too.

This pull request

  • Drops en-US from supported-languages.json. Fluent strips the region and resolves en-US to en, so we serve the English bundle we actually deploy.
  • Adds a case to supported-languages.spec.ts that keeps en-US out of the list. JSON holds no comments, so the test carries the reason.
  • Adds parseAcceptLanguage and determineLocale cases for en-US, and updates the existing expectations in l10n.utils.spec.ts.
  • Moves the en-US fixtures in AppLocalizationProvider.test.tsx and NimbusContext.test.tsx to en-CA, a locale we do deploy.
  • Adds a NimbusContext case for the region change described below.

I picked removal over an EN_GB_LOCALES-style alias. An alias fixes the en-US header but not the en header, which still expands to en-US through the available-range match, so the 404 would stay.

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-10363

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: libs/shared/l10n/src/lib/supported-languages.json is the whole fix. The rest follows from it.
  • Suggested review order: the JSON, then l10n.utils.spec.ts, then the two consumer tests.
  • Risky or complex parts: two behaviour changes ride along.
    • NimbusContext derives its Nimbus targeting region from the negotiated locale. An en-US user used to send region: "us" and now sends no region. If any experiment targets US, that needs a follow-up ticket. There is a test for the new behaviour, but I did not widen this PR to change it.
    • The fxa-settings language switcher builds its option list from the same JSON, so "English (US)" drops off it. Those users get the en strings they were already served after the 404.

Screenshots (Optional)

Other information (Optional)

Local runs: shared-l10n 89 passed, fxa-react 106 passed, accounts-email-renderer 122 passed, fxa-settings locale tests 38 passed, all with 0 failures. nx lint is clean for the four projects.

LOCALE_MAPPINGS in packages/fxa-settings/src/lib/locales.ts still holds an en-US entry. The switcher filters that map by the supported list, so the entry is now unreachable. I left it alone rather than touch a file this ticket does not need.

## Because

- `supported-languages.json` lists `en-US`, but the l10n repo only ships `en`, `en-CA` and `en-GB`. Every page load asked for `.../en-US/main.ftl` and got a 404, so the request could never be a cache hit.
- Negotiation made that unavoidable. `en-US` matched itself, and a plain `en` header expanded to every `en-*` entry in the list, which pulled `en-US` in too.

## This pull request

- Drops `en-US` from `supported-languages.json`. Fluent strips the region and resolves `en-US` to `en`, so we serve the English bundle we actually deploy.
- Adds a case to `supported-languages.spec.ts` that keeps `en-US` out of the list. JSON holds no comments, so the test carries the reason.
- Adds `parseAcceptLanguage` and `determineLocale` cases for `en-US`, and updates the existing expectations in `l10n.utils.spec.ts`.
- Moves the `en-US` fixtures in `AppLocalizationProvider.test.tsx` and `NimbusContext.test.tsx` to `en-CA`, a locale we do deploy.
- Adds a `NimbusContext` case for the region change described below.

I picked removal over an `EN_GB_LOCALES`-style alias. An alias fixes the `en-US` header but not the `en` header, which still expands to `en-US` through the available-range match, so the 404 would stay.

## Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-10363
@vbudhram
vbudhram requested a review from a team as a code owner August 31, 2026 20:30
Copilot AI balanced review requested due to automatic review settings August 31, 2026 20:30
@vbudhram vbudhram added the auto label Aug 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes undeployed en-US localization resources from locale negotiation, preventing repeated FTL 404s.

Changes:

  • Removes en-US from supported locales.
  • Updates negotiation and formatting expectations to resolve en-US to en.
  • Replaces test fixtures with deployed en-CA resources and verifies Nimbus region behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libs/shared/l10n/src/lib/supported-languages.json Removes unsupported en-US.
libs/shared/l10n/src/lib/supported-languages.spec.ts Guards against reintroducing en-US.
libs/shared/l10n/src/lib/l10n.utils.spec.ts Updates locale negotiation expectations.
libs/accounts/email-renderer/src/renderer/email-helpers.spec.ts Verifies email locale fallback.
packages/fxa-react/lib/AppLocalizationProvider.test.tsx Uses deployed en-CA fixtures.
packages/fxa-settings/src/models/contexts/NimbusContext.test.tsx Tests updated Nimbus region targeting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vbudhram

vbudhram commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

This PR lgtm, it is small change.

@vbudhram
vbudhram merged commit bd78c26 into main Sep 1, 2026
22 checks passed
@vbudhram
vbudhram deleted the fxa-10363 branch September 1, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants