Skip to content

feat(ui): add an in-app language switcher to the graph UI #1668

Description

@zhangweildlh

Summary

The graph UI already ships complete, parallel English and Simplified-Chinese message catalogs in graph-ui/src/lib/i18n.ts (messages.en / messages.zh), and the backend already computes and exposes a lang field from GET /api/ui-config — derived from the ui-lang config key (CBM_CONFIG_UI_LANG, default auto) or the request's Accept-Language (detect_ui_lang).

However, there is currently no in-app control to choose the language. A user who wants Chinese today must either set CBM_CONFIG_UI_LANG=zh out-of-band (CLI / config store) or change their browser language. The UI itself offers no selector.

Proposal

Add a small, non-breaking language switcher to the UI header with three options:

  • 中文 (zh)
  • English (en)
  • 跟随浏览器 (auto)

Behavior:

  • The selection is persisted by a new POST /api/ui-config endpoint that writes CBM_CONFIG_UI_LANG (en / zh / auto) via the existing cbm_config_set path already opened by handle_ui_config (src/ui/http_server.c).
  • GET /api/ui-config is unchanged (still returns lang + upstream_issues_url).
  • The frontend i18n.ts gains a setUiLanguage() that POSTs the choice, then updates cachedLanguage and notifies listeners so the whole UI re-renders immediately.
  • Default remains auto — no behavior change for existing users.

Scope / constraints

  • Pure C for the binary change; React/TS for the frontend.
  • Adds tests in tests/test_httpd.c (POST path) and graph-ui/src/lib/i18n.test.ts.
  • No new dependencies, no new network egress, no hardcoded external URLs (the issues URL stays backend-served per the existing UI security audit).
  • Kept under the 500-line / single-issue guidance.

Ask

I'd like to contribute this as a PR. Posting here first per CONTRIBUTING ("open an issue first"). Happy to adjust the endpoint shape or selector placement to your preference before implementing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions