feat(i18n): en/ko localization with dictionary + cookie-driven provider - #104
Open
sigco3111 wants to merge 1 commit into
Open
feat(i18n): en/ko localization with dictionary + cookie-driven provider#104sigco3111 wants to merge 1 commit into
sigco3111 wants to merge 1 commit into
Conversation
- Add lib/i18n/ (Locale union, dictionaries, translator API, server + client)
- Wire LocaleProvider into app/layout.tsx, hydrate <html lang> from cookie
- Convert ScoutForm, LoadingScreen, HowItWorksModal, ResultView, DuelView
(incl. duel stat row labels + receipts + share/draw headlines),
FlagPicker (country names), 404/error pages to the i18n API
- Translate the scoring engine's archetype blurbs, playstyle names,
metric labels, style and workRate reasons
- Add LocaleToggle in the AppShell corner (cookie write + custom event)
- Pin buildCard() locale='en' for OG / JSON endpoints (locked keys: t('@...'))
- Add 250-entry countries table (priority KO overrides + EN fallback)
- Add tests/i18n.test.ts covering dictionary parity, fallback chains,
negotiateLocale, format helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces full English + Korean localization for GitFut without
changing the visual identity of any surface.
string (scoring archetypes, playstyle names, metric labels, style and
workRate reasons, scout form copy, how-it-works modal, duel view,
error/404 screens, country names) lives in a typed dictionary.
the server (so the first paint is correctly localized) and writes it on
the client when the user toggles. reflects the active locale.
— social cards carry the brand read, not the viewer's locale.
(and vice versa); adding a key to one without the other now fails CI.
What changed
dictionary loader, translator API (t("...", locale, params), typed
helpers for archetype/playstyle/metric/duel stat-row/duel receipt/country
name), server resolver, client cookie helpers, hooks.
next to the Star button.
derivePlaystyles, deriveSkillMoves, deriveWeakFoot, deriveWorkRate,
deriveStyle, deriveMetrics. Tests stay identical (default locale is EN).
labels localize; lib/og/renderCard keeps EN because OG cards are brand read.
locale) reads from the dictionary with EN fallback.
keys) — KO dictionary overrides priority subset (Korea, Japan, USA, WC26
hosts, EU neighbours, etc.) and falls back to EN for the rest.
Tested
tests/i18n.test.ts — 19 new tests covering dictionary loading, fallback
for unknown locale, key-set parity, locale negotiation (Accept-Language
parsing, quality factors, region stripping), isLocale / localeFromCookie
guards, t.stat / t.metric / t.style / t.playstyle / t.workRate_reason /
t.attribute.skillMoves / t.attribute.weakFoot, @locked key prefix (always
returns EN), formatCount / formatInt accepting the locale.
npm test → 296/296 passing. npx tsc --noEmit → 0 errors.
Notes
(METRIC_LABELS, FINISH_LABELS) rather than introducing a new i18n library.
The translator is plain TypeScript so there's no new dependency.
brand reads that don't localize — left as-is.
hero + reads section + ladder labels).