Conversation
Mirrors the alias map in agent/i18n.py so user-supplied values from config.yaml or legacy localStorage entries route to the right catalog instead of silently falling back to English. Refs NousResearch#26665
…usResearch#26665) The Desktop only read the locale from localStorage, so users who set `display.language` in `~/.hermes/config.yaml` directly (e.g. via the CLI setup wizard) saw English on every restart even though the value was saved. Fetch `display.language` from `/api/config` on mount and apply it when the user has not explicitly chosen a language via the in-browser dropdown — an explicit dropdown choice still wins. Fixes NousResearch#26665
Adds regression coverage for the specific aliases called out in the bug report so future refactors of the alias map can't silently route Portuguese users back to English.
e2e8497 to
6e68ef4
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the dashboard fallback and reusing the existing /api/config API.
Problems
- The reported issue is for native Desktop, but this diff changes the separate web dashboard surface.
apps/desktop/AGENTS.md:11-24distinguishes them; native Desktop already loadsdisplay.languageinapps/desktop/src/i18n/context.tsx:107-112, while its locale type does not include Portuguese (apps/desktop/src/i18n/types.ts:8). This dashboard-only change therefore cannot by itself fix the reportedpt-BRDesktop behavior. - The regression coverage is in
tests/agent/test_i18n.py, not the changed web provider. It does not verify the new/api/configfallback or the localStorage-precedence contract inweb/src/i18n/context.tsx.
Suggested changes
- Confirm and state the intended surface: re-scope to
apps/desktopfor #26665, or present this as a dashboard-parity fix. - Add web-provider tests for config
pt-BRwith no stored locale and for an explicit stored locale taking precedence.
Automated hermes-sweeper review.
| assert i18n._normalize_lang("türkçe") == "tr" | ||
| # Regional Portuguese tags should both land on the shared `pt` catalog | ||
| # rather than silently falling back to English (#26665). | ||
| assert i18n._normalize_lang("pt-BR") == "pt" |
There was a problem hiding this comment.
These assertions cover the Python alias map, but the behavior added by this PR is in web/src/i18n/context.tsx. Please add a web-provider test that verifies /api/config display.language: "pt-BR" is applied only when no stored locale exists.
|
Closing: this patched |
What does this PR do?
Fixes #26665. Hermes Desktop ignored
display.languagefrom~/.hermes/config.yamlon startup, so non-English users (e.g.pt-BR) saw the UI in English on every restart even though the value was correctly saved on disk.The React
I18nProvider(web/src/i18n/context.tsx) only seeded the active locale fromlocalStorage. Users who set the language via the CLI setup wizard or by editingconfig.yamldirectly never populatedlocalStorage, so the provider always fell back to English. The same symptom appears in browsers that wipe site data on quit even when the user used the dropdown.This PR teaches the provider to fall back to
display.languagefrom/api/configwhenlocalStoragehas no entry, mirrors the Python alias map (pt-BR→pt,zh-CN→zh, etc.) on the TypeScript side so the same string resolves identically across Desktop / CLI / gateway, and pins a regression test for the specific Portuguese aliases called out in the bug report. An explicit dropdown choice still wins, so the existing in-browser UX is unchanged. The fix is read-only on the config side — it never mutatesconfig.yaml.Related Issue
Fixes #26665 — Desktop language setting resets to English on restart despite
config.yamlhavingpt-BRsaved.Type of Change
Changes Made
web/src/i18n/context.tsx(+74/-4):LOCALE_ALIASESmap covering BCP-47 regional tags and a few endonym/English aliases — mirrors_LANGUAGE_ALIASESinagent/i18n.pyso Desktop, CLI, and gateway resolve user input identically.normalizeLocale(value)helper that accepts the alias map plus a regional-suffix strip (zh-XX→zh) and returnsnullfor unknown input.getInitialLocale()to route stored values throughnormalizeLocale.fetchConfigLocale()helper that callsapi.getConfig()and readsdisplay.language.useEffectinI18nProviderthat, only whenlocalStoragehas no entry, applies the config-derived locale on mount. An explicit dropdown choice — saved tolocalStorage— always wins.tests/agent/test_i18n.py(+5):pt-BR,pt-PT, andbraziliancases totest_normalize_lang_accepts_aliasesso future refactors of the Python alias map can't silently route Portuguese users back to English.No backend code or config-write path touched.
How to Test
.venvis set up:display.language: pt-BRin~/.hermes/config.yaml.hermes-localekey inlocalStorage).Françaisfrom the dropdown, reload the page → UI stays French even thoughconfig.yamlstill sayspt-BR(localStorage wins).config.yamlwithoutdisplay.language→ UI stays English.Checklist
Code
feat(web/i18n): ...,fix(web/i18n): ...,test(i18n): ...)scripts/run_tests.sh tests/agent/test_i18n.pyand all tests passpt-BR/pt-PT/brazilian)Documentation & Housekeeping
docs/, docstrings) — N/A; behavior matches existingdisplay.languagedocs, only the surface that honors it changedcli-config.yaml.exampleif I added/changed config keys — N/A, no new keysCONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs