Skip to content

feat(i18n): prepare internationalization message catalogue and Intl formatting (closes #80) - #115

Open
shobhamerabacha-star wants to merge 1 commit into
FinesseStudioLab:mainfrom
shobhamerabacha-star:feat/i18n-message-catalogue-and-intl-formatting
Open

shobhamerabacha-star wants to merge 1 commit into
FinesseStudioLab:mainfrom
shobhamerabacha-star:feat/i18n-message-catalogue-and-intl-formatting

Conversation

@shobhamerabacha-star

Copy link
Copy Markdown

Summary

Closes #80

Prepares ModelTrace for internationalization by introducing a stable message catalogue architecture, adopting Next.js i18n routing (English-only active locale), replacing ambiguous hand-formatted numbers/currencies/dates with standard Intl formatters, and length-proofing responsive layouts for text expansion (such as German and Finnish).

Key Changes

  • Message Catalogue & Translation Engine (lib/i18n/):
    • lib/i18n/config.ts: Configured DEFAULT_LOCALE = 'en', SUPPORTED_LOCALES = ['en'], and bidirectional text direction detection (getLocaleDirection) with RTL readiness (Arabic, Hebrew, Persian, Urdu).
    • lib/i18n/messages/en.ts: Structured, canonical message catalogue covering common, home, operators, compliance, and errors.
    • lib/i18n/index.ts: Type-safe dot-notated lookup t(key, params?) with variable interpolation and resilient fallback.
  • Next.js i18n Routing Middleware (middleware.ts):
    • Implemented Next.js request middleware resolving locale and injecting x-locale, Content-Language, and x-direction headers.
  • Standardized Intl Formatting (lib/i18n/formatters.ts):
    • formatNumber, formatCurrency (USD/EUR/XLM), formatPercent, formatCompactNumber (e.g. 1.2M), formatDate, formatDateTime, and formatTime preventing financial figure misinterpretations across regions.
  • Component & View Integration:
    • app/layout.tsx: Configured root <html lang="en" dir="ltr">.
    • app/page.tsx: Wired landing headline, lead, CTAs, stats, and pillars to message catalogue.
    • components/site-footer.tsx: Wired footer text and repository link label to message catalogue.
    • app/operators/components/SettlementsPanel.tsx: Replaced ad-hoc number formatting with formatCompactNumber and localized labels.
    • app/operators/components/QuotasPanel.tsx: Formatted used/limit quotas via formatNumber and formatPercent.
    • app/operators/components/AttestationsPanel.tsx: Formatted timestamps and token counts via formatTime and formatNumber.
  • Layout Length-Proofing & RTL Foundations (app/globals.css):
    • Added overflow-wrap: break-word, hyphens: auto, and flex-wrap wrapping for buttons, pills, cards, and tables ensuring layouts remain stable when strings expand 30-50% in languages like German or Finnish.
    • Added [dir="rtl"]: bidirectional alignment and spacing foundations.
  • Unit Testing Suite (tests/unit/i18n.test.ts):
    • 14 vitest unit tests validating i18n configuration, RTL detection, message lookup, parameter interpolation, number/currency/percent/compact formatters, date/time formatters, and layout string expansion resilience (+35% text length).

Verification

  • npm test: 24/24 test files passed, 150/150 tests passing green (100%).
  • npm run lint: 0 ESLint warnings or errors.
  • npm run build (next build): Production build compiled and generated all 21 static pages successfully.

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.

ops: prepare for internationalization without shipping translations yet

1 participant