Skip to content

feat(i18n): add English (UK) locale - #303

Open
Mallard-Marsh wants to merge 1 commit into
Anyesh:mainfrom
Mallard-Marsh:pr/en-gb
Open

Mallard-Marsh wants to merge 1 commit into
Anyesh:mainfrom
Mallard-Marsh:pr/en-gb

Conversation

@Mallard-Marsh

@Mallard-Marsh Mallard-Marsh commented Oct 27, 2026 •

Copy link
Copy Markdown

Description

Adds English (UK) as a supported language, so UK users see Trousers, Jumper, Trainers, Waistcoat, Autumn and Grey instead of Pants, Sweater, Sneakers, Vest, Fall and Gray, with British spelling throughout (colour, favourite, analyse).

  • messages/en-GB/ is generated from messages/en by scripts/gen-en-gb.mjs: a spelling pass over every string (ICU argument names and selectors are masked so placeholders and plural keys are never changed), plus whole-string replacements in i18n/en-GB-overrides.json for the words that need more than spelling (garment names, Autumn, Grey, a few subtypes and two analytics sentences).
  • The files are full copies rather than a thin overlay because request.ts merges a locale over en only per namespace and i18n:parity requires every key. npm run i18n:en-gb regenerates them; npm run i18n:check now also fails when they are stale, so a new en string can't be forgotten.
  • en-GB is added to backend/app/data/locales.json (and the generated lib/generated/locales.ts), with a LOCALE_METADATA entry. The picker labels en as English (US) next to English (UK).
  • A browser set to British English (en-GB) now resolves to English (UK) on first visit; other English browsers still get en.
  • The backend gets "British English" as the AI description language for en-GB, so item descriptions follow the user's language like the other locales.
  • CONTRIBUTING gains a short note on regenerating en-GB after editing en strings.

Contributors don't need to translate anything by hand for en-GB: editing messages/en and running npm run i18n:en-gb keeps it in step.

Related Issue

Fixes #269

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or build changes

Checklist

  • I have read the CONTRIBUTING guide
  • My code follows the project's coding style
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation as needed
  • My changes don't introduce new warnings or errors

Testing

Test Environment

  • Docker Compose
  • Kubernetes
  • Local development

Tests Performed

  • frontend: tsc --noEmit, vitest (706 passing), npm run i18n:check (keys, parity, scan, and the new stale-en-GB check), npm run vocab:check. tests/en-gb-locale.test.ts covers the spelling pass (capitalisation kept, ICU argument names untouched, whole-word matching, clothing words swapped but not words containing them), the generated catalogues (British clothing words, keys unchanged) and browser detection (a British browser gets en-GB, other English browsers get en).
  • backend: ruff, full pytest (same 4 macOS-only failures as main: 2 in test_tagging_durability, 2 [utc] timezone cases); the locale list and description-language tests updated for en-GB.
  • Rebased on current main; regenerating en-GB after the rebase produced no changes.
  • In daily use for about a week on a self-hosted instance (Docker Compose on a NAS) with the account set to English (UK).

Additional Notes

Two small related fixes from the same testing are in my fork and can follow as separate PRs if useful: a new device adopting the account's saved language instead of the browser's, and promoting a type name the AI returns as the subtype ("sneakers" as the subtype of "shoes").

Summary by Sourcery

Support English (UK) across the frontend and backend with generated British-English catalogues, locale detection, and localized AI descriptions.

New Features:

  • Add English (UK) as a supported locale with British spelling and wardrobe terminology throughout the interface.
  • Detect British English browser preferences and provide British English item descriptions from the backend.

Enhancements:

  • Generate the English (UK) catalogues from the English source with configurable terminology overrides while preserving translation keys and ICU placeholders.
  • Update locale metadata so English is labelled English (US) alongside English (UK).

Build:

  • Add commands to generate English (UK) catalogues and verify that generated files are up to date.

Documentation:

  • Document the English (UK) catalogue regeneration workflow for contributors.

Tests:

  • Add coverage for British spelling, terminology substitutions, ICU placeholder preservation, generated catalogue integrity, and browser locale resolution.
  • Update backend locale and AI description language tests for English (UK).

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Sorry @Mallard-Marsh, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 7 days by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds English (UK) as a fully supported locale by generating an ICU-safe, British-spelled catalog from English (US), applying targeted terminology overrides, wiring the locale through frontend and backend metadata and AI descriptions, and enforcing catalog freshness in tests and i18n checks.

Sequence diagram for English UK locale selection

sequenceDiagram
    participant User
    participant Picker as Locale picker
    participant App
    participant Backend
    participant AI as AI service

    User->>Picker: Select English UK
    Picker->>App: Store locale en-GB
    App->>Backend: Request with locale en-GB
    Backend->>AI: Generate description with British English
    AI-->>Backend: British English description
    Backend-->>App: Localized response
    App-->>User: Display English UK catalog
Loading

Flow diagram for generated English UK locale catalogs

flowchart LR
    EN[English US message catalogs] --> GEN[gen-en-GB.mjs]
    OV[en-GB overrides] --> GEN
    GEN --> UK[English UK catalogs]
    UK --> CHECK[i18n check --check]
    EN --> CHECK
    CHECK -->|stale or missing| FAIL[Check fails]
    CHECK -->|up to date| PASS[Check passes]
Loading

File-Level Changes

Change Details Files
Adds a generated English (UK) message catalog derived from English (US), combining protected ICU-aware spelling conversion with explicit whole-string terminology overrides.
  • Introduces the en-GB generator and check mode.
  • Masks ICU arguments and selectors before applying British spelling and clothing-word conversions.
  • Adds overrides for terminology that cannot be handled safely by generic spelling rules.
  • Commits complete en-GB namespace copies and tests spelling, placeholders, keys, and generated output behavior.
frontend/scripts/gen-en-GB.mjs
frontend/i18n/en-GB-overrides.json
frontend/messages/en-GB/analytics.json
frontend/messages/en-GB/common.json
frontend/messages/en-GB/constants.json
frontend/messages/en-GB/dashboard.json
frontend/messages/en-GB/errors.json
frontend/messages/en-GB/family.json
frontend/messages/en-GB/history.json
frontend/messages/en-GB/learning.json
frontend/messages/en-GB/nav.json
frontend/messages/en-GB/notifications.json
frontend/messages/en-GB/onboarding.json
frontend/messages/en-GB/outfits.json
frontend/messages/en-GB/pairings.json
frontend/messages/en-GB/settings.json
frontend/messages/en-GB/suggest.json
frontend/messages/en-GB/wardrobe.json
frontend/tests/en-gb-locale.test.ts
Integrates en-GB across locale registration, selection metadata, generated locale types, and localized AI descriptions.
  • Registers en-GB as a supported backend locale and frontend locale metadata.
  • Renames the existing English picker label to English (US) and adds English (UK).
  • Uses British English for AI-generated item descriptions.
  • Extends backend locale acceptance and description-language tests.
backend/app/data/locales.json
backend/app/services/ai_service.py
backend/tests/test_ai_service.py
backend/tests/test_users.py
frontend/lib/generated/locales.ts
frontend/lib/i18n/locales.ts
Adds safeguards and contributor guidance to keep the generated UK catalog synchronized with English source strings.
  • Adds an i18n:en-gb generation command.
  • Makes i18n:check fail when generated en-GB files are stale or have obsolete namespaces.
  • Documents that en-GB files must not be edited manually and should be regenerated after English changes.
frontend/package.json
CONTRIBUTING.md

Assessment against linked issues

Issue Objective Addressed Explanation
#269 Add en-GB as a supported locale that users can select and that resolves correctly for British English preferences. ✅
#269 Provide British English UI wording, including the requested clothing vocabulary and spelling, while keeping translations in sync with the English source. ✅
#269 Use British English for AI-generated clothing descriptions when the owner’s locale is en-GB. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions Bot added javascript Pull requests that update javascript code python Pull requests that update python code labels Oct 27, 2026
Adds en-GB as a supported locale so UK users see Trousers, Jumper,
Trainers, Autumn and Grey instead of Pants, Sweater, Sneakers, Fall and
Gray, with British spelling throughout (colour, favourite, analyse).

messages/en-GB/ is generated from messages/en by scripts/gen-en-gb.mjs:
a spelling pass over every string (ICU argument names and selectors are
masked) plus whole-string replacements in i18n/en-GB-overrides.json for
words that need context. The files are full copies because request.ts
merges a locale over en only per namespace and i18n:parity requires every
key. `npm run i18n:en-gb` regenerates them and i18n:check fails while they
are stale.

The backend gets "British English" as the AI description language, and
the picker labels en as English (US) next to English (UK).

Refs Anyesh#269

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

Labels

javascript Pull requests that update javascript code python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add an English (UK) / en-GB locale (trousers, jumper, trainers, colour)

2 participants