Repository navigation
Closed
Labels
Description
Refs: #372
Depends on: #376, #377, #378, #379, #380
Context
All 5 component migration batches (#376–#380) are now complete, and every view in frontend/src has migrated to useTranslations(), createTranslator, and the central language registry.
This issue is the sole owner of legacy removal. It eliminates the legacy custom translation engine, the old useI18n() hook, the regex ICU plural parser, and the temporary compatibility bridge, leaving a clean, modular architecture.
What to do
1. Reorganize Surviving Utilities into Focused Modules
Move surviving non-legacy utilities into clear, dedicated modules:
- Browser Language Detection ->
frontend/src/lib/i18n/browser-language.ts:
BCP-47 parsing and matching viaIntl.Localeagainst registered selectable languages:import { LANGUAGES, type Language } from './languages'; export function getBrowserLanguage(): Language { if (typeof navigator === 'undefined' || !navigator.languages?.length) return 'en'; for (const raw of navigator.languages) { try { const parsed = new Intl.Locale(raw); for (const [code, config] of Object.entries(LANGUAGES)) { if (!config.selectable) continue; const regLocale = new Intl.Locale(config.locale); if (parsed.language === regLocale.language) { return code as Language; } } } catch { // Continue on invalid locale tag } } return 'en'; }
- Server Language Synchronization ->
frontend/src/lib/i18n/server-language.ts:
ContainsfetchServerInfoanduseSyncServerLanguagefor standalone KDS and Server App language sync. - Domain Enum Mappings ->
frontend/src/lib/i18n/enums.ts(ori18n-enums.ts):
Exhaustively typed mappings from backend status strings to translation keys. - Shared Loader & Cache ->
frontend/src/lib/i18n/loader.ts:
Shared message loader, in-flight promise deduplication, and in-memory cache.
2. Remove Legacy Files & Artifacts
- Delete
frontend/src/hooks/useI18n.ts. - Remove legacy implementations from
frontend/src/lib/i18n.ts:- Delete old synchronous
t(key, lang, params)function. - Delete
formatIcuPluralregex parser and plural rules cache. - Delete static translation map and compatibility wrapper.
- Delete old synchronous
- Either remove
frontend/src/lib/i18n.tsentirely or keep it purely as a clean re-export barrel for the modular i18n subsystem.
3. Add CI Guardrail Against Legacy Regressions
Update tests/translations.test.ts to assert that:
- No file in
frontend/src/imports or referencesuseI18n. - No file in
frontend/src/references the removed customformatIcuPlural. - No unchecked dynamic translation calls exist.
What NOT to do
- Do NOT modify translation JSON files in
frontend/src/lib/i18n/messages/. - Do NOT touch
I18nProvider.tsxor the language registry inlanguages.ts. - Do NOT delete
server-language.tsor break KDS language synchronization.
Acceptance Criteria
-
frontend/src/hooks/useI18n.tsis deleted. - Legacy custom
t(), regex plural formatter, and compatibility wrapper removed. - Surviving utilities modularized into
browser-language.ts,server-language.ts, andloader.ts. - BCP-47 browser language matching is robust against regional and script subtags.
- Zero references to
useI18nremain in the codebase. - All standard checks and full test suites pass.
Verification
# Verify zero legacy callers
grep -r "useI18n" frontend/src/ # must return 0 results
grep -r "formatIcuPlural" frontend/src/ # must return 0 results
npm run lint
npm run build:frontend
npm test
npm run test:translations
Activity
refactor(i18n): migrate shared, auth, and setup components to use-intl (
refactor(i18n): migrate settings, admin, catalog, and WhatsApp to use…
refactor(i18n): remove legacy custom i18n implementation and modulari…
khaira777 commentedon Aug 19, 2026
Completed by #410 (merged into main at commit 64f6076). All legacy hooks, custom engines, and formatters have been removed, surviving utilities modularized, and CI guardrails verified.
Merge origin/main into main