Skip to content

feat: i18n foundation (#461)#1

Merged
Awointa merged 1 commit into
mainfrom
feature/i18n-foundation
Jul 23, 2026
Merged

feat: i18n foundation (#461)#1
Awointa merged 1 commit into
mainfrom
feature/i18n-foundation

Conversation

@Awointa

@Awointa Awointa commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Set up the translation message-catalog layer on top of the existing
language-preference infrastructure.

New files
─────────
app/i18n/types.ts
Messages, MessageKey, InterpolationValues type definitions.

app/i18n/messages/en.ts
English base catalog (160+ keys across nav, auth, dashboard, events,
predictions, wallet, settings, disputes, finances, profile, errors,
feedback, and a11y namespaces).

app/i18n/messages/index.ts
Synchronous catalog loader with English fallback; exposes
getMessages(), AVAILABLE_LOCALES, and defaultMessages.

app/i18n/t.ts
interpolate() – {variable} placeholder substitution
createTranslator() – builds a t() function from a catalog
getTranslator() – server-safe helper (reads stored locale)
useTranslation() – React hook; reactive t() for client components

app/i18n/LangAttribute.tsx
Invisible client component; keeps in sync with the
user's active locale on hydration and change.

app/i18n/tests/t.test.ts
31 tests covering interpolate, createTranslator, getTranslator,
getMessages, defaultMessages catalog integrity, and AVAILABLE_LOCALES.

Modified files
──────────────
app/i18n/index.ts
Extended with re-exports for all new types and utilities.
Existing Language/SUPPORTED_LANGUAGES/getStoredLanguage/saveLanguage
surface is unchanged – no breaking changes.

components/providers.tsx
Mounts to keep document lang current.

app/settings/language/page.tsx
Demonstration integration: uses useTranslation() for all user-visible
strings (page heading, description, active label, helper note,
fieldset aria-label).

Test results
────────────
New: 31 passed, 0 failed (app/i18n/tests/t.test.ts)
Existing: 539 passed (vs 508 before), 19 failed (vs 20 before)
Lint: ESLint binary not present in this environment (pre-existing)

Closes Predictify-org#461

Set up the translation message-catalog layer on top of the existing
language-preference infrastructure.

New files
─────────
app/i18n/types.ts
  Messages, MessageKey, InterpolationValues type definitions.

app/i18n/messages/en.ts
  English base catalog (160+ keys across nav, auth, dashboard, events,
  predictions, wallet, settings, disputes, finances, profile, errors,
  feedback, and a11y namespaces).

app/i18n/messages/index.ts
  Synchronous catalog loader with English fallback; exposes
  getMessages(), AVAILABLE_LOCALES, and defaultMessages.

app/i18n/t.ts
  interpolate()   – {variable} placeholder substitution
  createTranslator() – builds a t() function from a catalog
  getTranslator()    – server-safe helper (reads stored locale)
  useTranslation()   – React hook; reactive t() for client components

app/i18n/LangAttribute.tsx
  Invisible client component; keeps <html lang> in sync with the
  user's active locale on hydration and change.

app/i18n/__tests__/t.test.ts
  31 tests covering interpolate, createTranslator, getTranslator,
  getMessages, defaultMessages catalog integrity, and AVAILABLE_LOCALES.

Modified files
──────────────
app/i18n/index.ts
  Extended with re-exports for all new types and utilities.
  Existing Language/SUPPORTED_LANGUAGES/getStoredLanguage/saveLanguage
  surface is unchanged – no breaking changes.

components/providers.tsx
  Mounts <LangAttribute /> to keep document lang current.

app/settings/language/page.tsx
  Demonstration integration: uses useTranslation() for all user-visible
  strings (page heading, description, active label, helper note,
  fieldset aria-label).

Test results
────────────
New:       31 passed, 0 failed  (app/i18n/__tests__/t.test.ts)
Existing: 539 passed (vs 508 before), 19 failed (vs 20 before)
Lint:      ESLint binary not present in this environment (pre-existing)

Closes Predictify-org#461
@Awointa
Awointa merged commit 6b4cd21 into main Jul 23, 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.

Add localization foundation (i18n)

1 participant