Skip to content

feat(sight): bootstrap dashboard i18n - #2334

Open
yefuyou wants to merge 2 commits into
alibaba:mainfrom
yefuyou:feature/sight/dashboard-i18n
Open

feat(sight): bootstrap dashboard i18n#2334
yefuyou wants to merge 2 commits into
alibaba:mainfrom
yefuyou:feature/sight/dashboard-i18n

Conversation

@yefuyou

@yefuyou yefuyou commented Aug 8, 2026

Copy link
Copy Markdown

Screenshots

Login page

login-en-US login-zh-CN

Navigation bar

navbar-en-US navbar-zh-CN

Summary

This draft PR bootstraps dashboard internationalization for AgentSight.

  • Supports en-US and zh-CN with a typed React context and in-module resources.
  • Keeps locale detection and persistence in the provider, with no new runtime dependency.
  • Limits the initial migration to the application shell, navigation, login flow, and document metadata.
  • Keeps the change frontend-only; there are no API, authentication, backend, Rust, or build-configuration changes.

Changed files

  • src/agentsight/dashboard/index.html
  • src/agentsight/dashboard/src/App.tsx
  • src/agentsight/dashboard/src/components/NavBar.tsx
  • src/agentsight/dashboard/src/index.tsx
  • src/agentsight/dashboard/src/pages/LoginPage.tsx
  • src/agentsight/dashboard/src/i18n.tsx

Behavior

  • Detects the initial locale from a supported persisted locale first, then the browser language.
  • Safely falls back to en-US when the persisted locale is missing or invalid.
  • Persists locale changes in localStorage so the choice survives refresh.
  • Synchronizes document.documentElement.lang and document.title.
  • Internationalizes the login page, navigation labels, loading text, login errors, browser title, and html lang.
  • Adds language switchers to the login page and navigation bar.
  • Keeps navigation usable at the 1024px narrow-screen layout by allowing natural wrapping.

Validation

Completed checks:

  • typecheck
  • build
  • build:embed
  • API regression: 10/10
  • cargo fmt --all --check (Rust 1.89)
  • cargo clippy --all-targets -- -D warnings (Rust 1.89)
  • git diff --check

The full cargo test run completed with 1,403 passed, 21 failed, and 1 ignored. The failures were limited to this Work environment's process visibility, PID lookup, and local socket permission constraints; no i18n-specific assertion failure was observed.

A real agentsight serve instance was started on 127.0.0.1:7396. Smoke E2E checks passed for /health, the embedded Dashboard root page, authentication status, and session, timeseries, and Agent API routes.

Four screenshots were visually checked. Chinese text and Emoji render correctly.

Browser verification covered language detection, invalid persisted locale handling, refresh persistence, translated error text, document.title, html lang, and the 1024px layout. No JavaScript/page errors or i18n-originated runtime errors were observed.

Related to #2331.

@CLAassistant

CLAassistant commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the component:sight src/agentsight/ label Aug 8, 2026
Add a typed React context with in-module en-US and zh-CN resources for the
Dashboard shell, navigation, login flow, and document metadata.

Keep locale detection and persistence in the provider without adding a runtime
i18n dependency. Leave business pages for follow-up work.

Signed-off-by: yefuyou <35551877+yefuyou@users.noreply.github.com>
@yefuyou
yefuyou force-pushed the feature/sight/dashboard-i18n branch from 6542896 to 196503d Compare August 9, 2026 10:08
@yefuyou
yefuyou marked this pull request as ready for review August 9, 2026 10:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 196503df72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agentsight/dashboard/src/i18n.tsx Outdated
Comment on lines +108 to +111
const preferredLanguage = browserLanguages.find(Boolean);
return preferredLanguage?.toLowerCase().startsWith('zh')
? 'zh-CN'
: DEFAULT_LOCALE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match all preferred browser locales

When a first-time visitor lists an unsupported language before a supported one—for example, navigator.languages is ['fr-FR', 'zh-CN']—this selects only the first nonempty entry and falls back to English, ignoring the user's supported Chinese preference. Iterate through the preference list and choose the first locale that can be matched before using the default.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 242d6c5. resolveLocale() now walks browser preferences in order and selects the first supported zh/en locale before falling back to en-US. Added regression coverage for mixed unsupported/supported preferences and persisted-locale priority.

Signed-off-by: yefuyou <35551877+yefuyou@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:sight src/agentsight/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants