Repository navigation
refactor(i18n): migrate shared, auth, and setup components to use-intl - #399
Merged
Merged
Conversation
#376) Phase 3 batch 5A: replace the legacy useI18n()/t() bridge in 12 shared, layout, auth, and setup components with useTranslations() from use-intl (namespace-scoped, compile-time key safety via the AppConfig augmentation). Sidebar nav labels and the setup profile/service-model cards now use exhaustively typed leaf-key mappings instead of template-literal keys, and the setup language selector derives its options from the LANGUAGES registry (selectable: true). HtmlLangSync and DirectionalToaster now read the active loaded locale from the i18n context (useLocale + registry reverse lookup), so document lang/dir and toast placement follow the atomically-loaded locale instead of the store request. Also folds in the deferred BCP-47 improvement: getBrowserLanguage() now parses navigator.language with Intl.Locale and matches the language subtag against the registry instead of string prefixes. The legacy bridge and useI18n hook stay intact for unmigrated batches (#381 owns removal). RTL evidence tests updated to wrap the context-driven components in IntlProvider.
27 tasks done
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): migrate shared, layout, auth, and setup components from the legacy useI18n()/t() bridge to useTranslations() from use-intl (epic #372, issue #376, Phase 3 batch 5A). 12 files in scope: AuthGuard, Sidebar, StatusBar, GlobalNotifications, MenuActionHandler, UpdateBadge, HtmlLangSync, DirectionalToaster, use-confirm, auth/login, auth/recover, setup. Use namespace-scoped leaf keys only, exhaustively typed key mappings (no template-literal dynamic keys), and derive setup language options from the LANGUAGES registry (selectable: true). HtmlLangSync and DirectionalToaster must read the active loaded locale from the i18n context (useLocale + getLanguageFromLocale reverse lookup) so lang/dir and toast placement follow the atomically loaded locale. Fold in the deferred BCP-47 improvement: getBrowserLanguage() parses navigator.language via Intl.Locale and matches the language subtag against LANGUAGES instead of string prefixes (behavior preserved: fa-IR/fa/fa-AF -> fa, es-ES -> es, pt-BR -> pt, en-US -> en, fr-FR/undefined -> en). Do NOT remove the legacy bridge or useI18n hook (#381 owns removal). Do NOT change translation wording, layout structure, API payloads, or product behavior. Update the two RTL evidence tests to wrap HtmlLangSync/DirectionalToaster renders in IntlProvider. Verification: npm run lint, npm run build, npm run build:frontend, npm test, plus focused suites test:rtl-setup-auth-settings, test:rtl-dashboard-pos-common, test:rtl-kds-server-whatsapp, test:translations, test:locale-chunks, test:first-run, test:auth-ui-deterministic. Note: local full-suite runs may hit pre-existing flaky backend suites (kds-contract, bills-print-api) that also fail on unmodified main and pass on retry.
What Changed
AuthGuard,Sidebar,StatusBar,GlobalNotifications,MenuActionHandler,UpdateBadge,HtmlLangSync,DirectionalToaster,use-confirm,login,recover, andsetup) fromuseI18n()touseTranslations()using namespace-scoped leaf keys and typed key lookup mappings.HtmlLangSyncandDirectionalToasterto resolve active language and text direction viauseLocale()withgetLanguageFromLocale(), and updatedgetBrowserLanguage()to parse BCP-47 language subtags usingIntl.Locale.rtl-dashboard-pos-commonandrtl-kds-server-whatsapp) to wrapDirectionalToasterandHtmlLangSynctest renders inIntlProvider.Risk Assessment
✅ Low: The i18n migration is well-bounded, strictly adheres to the scope and leaf-key typing requirements, preserves runtime behavior across all 12 components, and maintains backward compatibility with the legacy bridge.
Testing
Exercised all 12 migrated components across English, Spanish, Portuguese, and Persian locales using focused unit, RTL, chunk-splitting, deterministic auth, translation integrity suites, and automated Playwright browser end-to-end rendering. Captured 13 high-resolution UI screenshots and 2 rendered HTML evidence fixtures into the dedicated evidence directory demonstrating live translation switching, step-by-step setup progression, localized forms, and RTL/LTR directional synchronization with zero defects.
/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step1-en.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step1-es.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step1-pt.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step2-pin.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step3-owner.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step4-data-profile.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step5-cloud.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/setup-step6-flow.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/login-en.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/recover-en.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/layout-dashboard-en.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/rtl-toaster-persian-fa.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0C1DG6BFJDDFH7Z80A7J731/ltr-toaster-english-en.png)Evidence: Persian RTL direction test HTML fixture
Evidence: English LTR direction test HTML fixture
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:rtl-setup-auth-settingsnpm run test:rtl-dashboard-pos-commonnpm run test:rtl-kds-server-whatsappnpm run test:translationsnpm run test:locale-chunksnpm run test:first-runnpm run test:auth-ui-deterministicnpm run test:rtl-foundationnpm run build:frontendnpm run buildnode generate-all-evidence.js (Playwright headless Chromium end-to-end verification and visual evidence capture)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.