Skip to content

Add ICU plural/select support, new locale catalogs, and en-XA pseudo-locale - #564

Merged
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
aishabellova:drips/495
Sep 30, 2026
Merged

james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
aishabellova:drips/495

Conversation

@aishabellova

Copy link
Copy Markdown

Summary

Add ICU plural/select support, new locale catalogs, and en-XA pseudo-locale

What was solved

#495 — [High] Add new locale catalogs (pt-BR, fr, zh-CN) with ICU plurals, placeholder parity checks and a pseudo-locale for testing

Add ICU-style plural/select support to the i18n system via Intl.PluralRules, introduce pt-BR/fr/zh-CN catalogs plus a generated en-XA pseudo-locale, extend the parity checker to validate placeholders/plural categories/lengths, and wire the pseudo-locale into dev via ?lang=en-XA and the Storybook toolbar.

Addressed:

  • Changed: src/lib/i18n/index.ts, src/lib/i18n/messages/en.ts, scripts/check-i18n-parity.mjs
  • Catalog entries must support the ICU subset {count, plural, one {…} other {…}} (and select) resolved via Intl.PluralRules(locale).
  • The interpolate function must validate arguments and never throw — falling back to the key on error.
  • Add three fully translated locale catalogs: pt-BR, fr, zh-CN (RTL explicitly out of scope).

Changes

  • src/lib/i18n/index.ts (modify)
  • src/lib/i18n/messages/en.ts (modify)
  • scripts/check-i18n-parity.mjs (modify)

Approach

  1. Extend src/lib/i18n/index.ts with an ICU-subset parser/resolver (plural/select via Intl.PluralRules, {n, number} formatting, escaped braces) and a non-throwing interpolate that falls back to the key on error.
  2. Add pt-BR, fr, and zh-CN catalogs under src/lib/i18n/messages/ typed against the en catalog, plus a generated en-XA pseudo-locale (accented chars, ~40% expansion, brackets) exposed in dev via ?lang=en-XA.
  3. Extend scripts/check-i18n-parity.mjs to validate identical key sets, matching placeholder names, valid plural categories per locale, no empty strings, and max length ratio warnings without breaking existing en/es checks.
  4. Replace the manual plural ternary in src/app/contributors/ContributorsPageClient.tsx with the new ICU plural mechanism.
  5. Wire the en-XA pseudo-locale into the Storybook toolbar in .storybook/preview.tsx.
  6. Add parser tests (≥30 cases), parity-script fixture tests, and contributor docs on adding/reviewing a locale.

Issues

Closes #495

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@aishabellova Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

# Conflicts:
#	scripts/check-i18n-parity.mjs
#	src/lib/i18n/messages/en.ts
@james2177
james2177 merged commit 8b6cfe8 into stellar-vortex-protocol:main Sep 30, 2026
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.

[High] Add new locale catalogs (pt-BR, fr, zh-CN) with ICU plurals, placeholder parity checks and a pseudo-locale for testing

2 participants