feat(sight): bootstrap dashboard i18n - #2334
Conversation
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>
6542896 to
196503d
Compare
There was a problem hiding this comment.
💡 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".
| const preferredLanguage = browserLanguages.find(Boolean); | ||
| return preferredLanguage?.toLowerCase().startsWith('zh') | ||
| ? 'zh-CN' | ||
| : DEFAULT_LOCALE; |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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>
Screenshots
Login page
Navigation bar
Summary
This draft PR bootstraps dashboard internationalization for AgentSight.
en-USandzh-CNwith a typed React context and in-module resources.Changed files
src/agentsight/dashboard/index.htmlsrc/agentsight/dashboard/src/App.tsxsrc/agentsight/dashboard/src/components/NavBar.tsxsrc/agentsight/dashboard/src/index.tsxsrc/agentsight/dashboard/src/pages/LoginPage.tsxsrc/agentsight/dashboard/src/i18n.tsxBehavior
en-USwhen the persisted locale is missing or invalid.localStorageso the choice survives refresh.document.documentElement.langanddocument.title.html lang.Validation
Completed checks:
typecheckbuildbuild:embedcargo fmt --all --check(Rust 1.89)cargo clippy --all-targets -- -D warnings(Rust 1.89)git diff --checkThe full
cargo testrun 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 serveinstance was started on127.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.