Repository navigation
refactor(i18n): remove legacy custom i18n implementation and modularize utilities - #410
Merged
Merged
Conversation
- Delete legacy frontend/src/hooks/useI18n.ts hook. - Remove legacy custom synchronous t(), formatIcuPlural, and resolveMessage engine. - Modularize surviving utilities into browser-language.ts, server-language.ts, enums.ts, and index.ts. - Retain lib/i18n.ts and lib/i18n-enums.ts as clean re-export barrels. - Add CI guardrails in tests/translations.test.ts enforcing zero references to useI18n and formatIcuPlural with negative test coverage. - Update test-level translation assertions to use use-intl createTranslator.
Contributor
Greptile SummaryThe PR removes the unused custom translation engine and deprecated hook while preserving the remaining language, loader, server-sync, and enum utilities as focused modules.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code regression identified. The removed translation APIs have no remaining repository callers, compatibility imports continue to expose the surviving utilities, and the extracted modules preserve the prior helper behavior.
|
| Filename | Overview |
|---|---|
| frontend/src/lib/i18n.ts | Replaces the legacy implementation with compatibility re-exports for the modular subsystem; no remaining callers of removed APIs were found. |
| frontend/src/lib/i18n/browser-language.ts | Adds ordered BCP-47 browser-language detection with malformed-tag handling and an English fallback. |
| frontend/src/lib/i18n/server-language.ts | Extracts the existing best-effort server metadata fetch and language synchronization hook without changing their behavior. |
| frontend/src/lib/i18n/enums.ts | Relocates exhaustively typed domain-to-translation-key mappings while preserving the former compatibility export. |
| frontend/src/lib/i18n/index.ts | Adds a modular barrel exposing language, loader, browser, server, and enum utilities. |
| frontend/src/hooks/useI18n.ts | Deletes the deprecated hook after all repository callers migrated away from it. |
| tests/issue-241-localized-errors.test.ts | Migrates localized-error tests from the custom translator to use-intl translation infrastructure. |
| tests/rtl-kds-server-whatsapp.test.ts | Updates test translation setup to exercise the standard use-intl implementation. |
| tests/rtl-setup-auth-settings.test.ts | Updates test helpers and provider setup for the modular i18n implementation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Consumers[Application and test consumers] --> Root["@/lib/i18n compatibility barrel"]
Consumers --> Core["lib/i18n modular barrel"]
Root --> Languages[languages]
Root --> Loader[locale loader and cache]
Root --> Browser[browser-language]
Root --> Server[server-language]
Root --> Enums[domain enum keys]
Core --> Languages
Core --> Loader
Core --> Browser
Core --> Server
Core --> Enums
Provider[I18nProvider] --> Loader
Provider --> Browser
Provider --> IntlProvider[use-intl IntlProvider]
Reviews (1): Last reviewed commit: "no-mistakes(document): update stale i18n..." | Re-trigger Greptile
This was referenced Aug 19, 2026
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.
Intent
refactor(i18n): remove legacy custom i18n implementation and modularize surviving utilities into dedicated modules (#381)
What Changed
t(), dotted-key message resolver, ICU plural parser) and deleted the deprecateduseI18nhook.frontend/src/lib/i18n/(browser-language.ts,server-language.ts,enums.ts) with barrel re-exports.use-intl(createTranslator,IntlProvider) and cleaned up legacy doc comments.Risk Assessment
✅ Low: The legacy custom i18n implementation was cleanly removed and surviving utilities modularized without regressions.
Testing
Exercised targeted translation integrity, chunk splitting, RTL/LTR layout, localized error surfaces, Next.js static build, and modular i18n runtime validation across all four locales (en, es, pt, fa); all checks passed and generated HTML evidence.
Evidence: i18n-modular-verification.html
FloCafe modular i18n subsystem validation artifact rendering language registry, domain enum mappings across 4 locales (en, es, pt, fa), BCP-47 browser language detection matrix, and RTL component preview.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
tests/translations.test.ts:514- Newly added test helpers checkNoLegacyReferences (line 514) and checkNoLegacyEngine (line 539) read and regex-match raw TypeScript source code files for identifier strings ('useI18n', 'formatIcuPlural', 'export function t'), and lines 883-893 add negative test fixtures for source grepping. This violates the test-quality rule against source-content-only assertions. Verification should rely on compiler checks or executable interface assertions on the exported module instead of regex-matching source files.🔧 Fix: remove source-grepping assertions from translations test
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run test:translations(translation integrity, 2054 leaf key parity, ICU syntax, TypeScript key safety, Persian safeguards)npm run test:locale-chunks(lazy chunk splitting for non-English locales and offline asset packaging)npm run test:rtl-setup-auth-settings(logical direction utilities, Ltr polymorphic rendering, getBrowserLanguage)npm run test:rtl-kds-server-whatsapp(KDS/Server-App/WhatsApp direction rules, fetchServerInfo, useSyncServerLanguage)node tests/run-electron-node-test.cjs tests/issue-241-localized-errors.test.ts(PrinterStatus and POS error localization with use-intl)npm run test:rtl-foundation(direction foundation classes and Ltr isolation)npm run test:rtl-dashboard-pos-common(directional icons and DirectionalToaster placement)cd frontend && npx cross-env NEXT_BUILD_MODE=desktop npm run build(Next.js static export build across all 25 routes)npm run build(backend TypeScript compilation)npx ts-node --transpile-only -P tests/tsconfig.json scratch/verify-i18n.ts(evidence generator exercising modular barrel exports, enum mappings across en/es/pt/fa, browser detection)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.