← Back to PRs

#23813: Fix UI locale persistence

by kamal-ayman open 2026-02-22 18:21 View on GitHub →
app: web-ui agents size: XS
## Summary - *Problem:* The UI language setting was not being applied upon initial page load, even if a non-English language was stored in localStorage. - *Why it matters:* It caused a confusing user experience where the language dropdown showed one language (e.g., Chinese) while the entire interface remained in English until manually toggled. - *What changed:* Added a call to `this.notify()` at the end of the `loadLocale()` method in the `I18nManager` class. This ensures that all UI subscribers are informed of the correct locale immediately during the initialization phase. - *What did NOT change:* No changes were made to the translation files (`locales/*`) or the actual translation logic (`t` function). ## Change Type - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Docs - [ ] Security hardening - [ ] Chore/infra ## Scope - [ ] Gateway / orchestration - [ ] Integrations - [ ] API / contracts - [x] UI / DX - [ ] CI/CD / infra ## Linked Issue/PR - Closes #23784 ## User-visible / Behavior Changes The UI will now correctly display in the user's preferred (saved) language immediately upon opening the dashboard. ## Security Impact - New permissions/capabilities? (`No`) - Secrets/tokens handling changed? (`No`) - New/changed network calls? (`No`) - Command/tool execution surface changed? (`No`) - Data access scope changed? (`No`) ## Repro + Verification ### Environment - OS: Any (Web Browser) - Runtime/container: Browser - Model/provider: N/A - Integration/channel: Control UI (i18n subsystem) ### Steps 1. Open the Control UI and change the language to "简体中文" (Simplified Chinese). 2. Refresh the page. 3. Observe the UI language before the fix (remains English despite dropdown showing Chinese). 4. Apply fix and repeat. ### Expected - The UI should translate to Chinese immediately on load. ### Actual - The UI stayed in English until the language was manually changed again. ## Evidence - Verified by inspection of the `I18nManager` subscriber pattern. - Ran `pnpm build` to ensure UI builds correctly with the change. ## Human Verification - *Verified scenarios:* Initial load with English, initial load with Chinese (via localStorage). - *Edge cases checked:* Fallback to navigator language when localStorage is empty. - *What you did not verify:* Behaviour in legacy browsers without `localStorage` support. ## Compatibility / Migration - Backward compatible? (`Yes`) - Config/env changes? (`No`) - Migration needed? (`No`) ## Failure Recovery - How to disable/revert this change quickly: Revert the added line in `ui/src/i18n/lib/translate.ts`. - Files/config to restore: `ui/src/i18n/lib/translate.ts`. ## Risks and Mitigations - *Risk:* Minor performance hit during initialization if there are thousands of subscribers. - *Mitigation:* Currently, subscribers are limited to core UI components; the notification is instantaneous.

Most Similar PRs