feat: Add i18n localization foundation (#461)#513
Open
Awointa wants to merge 2 commits into
Open
Conversation
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
feat: i18n foundation (Predictify-org#461)
|
@Awointa is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Awointa 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! 🚀 |
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.
Closes #461