feat(i18n): add full English (US) support with browser auto-detect - #11
Open
erbanku wants to merge 4 commits into
Open
feat(i18n): add full English (US) support with browser auto-detect#11erbanku wants to merge 4 commits into
erbanku wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/erbanku/llmrelayservice/sessions/7458dbd5-b9cf-4680-8511-7a2e43a18e28 Co-authored-by: erbanku <79493862+erbanku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/erbanku/llmrelayservice/sessions/7458dbd5-b9cf-4680-8511-7a2e43a18e28 Co-authored-by: erbanku <79493862+erbanku@users.noreply.github.com>
Adds full English (US) i18n support to the console frontend (`console/ai-proxy-dashboard`). README.md/README.en.md language switchers and i18next/react-i18next setup already existed; this PR completes the remaining work: - **Browser language auto-detection**: added `i18next-browser-languagedetector`. Detection order is `localStorage` → `navigator`, persisted under the `lrs-console-lang` key, falling back to Chinese (`zh`) when detection is inconclusive. - **Manual language switcher**: added a toggle button (globe/languages icon) in the nav bar that switches between `zh` and `en` via `i18n.changeLanguage()`. - **Extracted remaining hardcoded Chinese UI strings** into i18n keys (with English translations) across `api-docs-page.tsx`, `routes-page.tsx`, and `providers-page.tsx`. Module-level constants that previously held static Chinese text (e.g., API docs endpoint list/body examples) were converted into functions parameterized by the translation function `t`, recomputed via `useMemo` whenever the active language changes. - **Locale-aware formatting**: `formatTime`, `formatCount`, `keys-page`'s `formatDateTime`, and the request-list `localeCompare` sort now use the active `i18n.language` instead of a hardcoded `zh-CN` locale. - **Comments**: added English translations alongside existing Chinese code comments throughout touched files (Chinese comments were not deleted, per repo convention). - **Changelog**: added `changelog/2026-07-29.md` documenting this work.
Docker multi-arch builds failed on bun install --frozen-lockfile because the committed lockfile drifted from package.json. Refresh bun.lock so CI installs stay deterministic.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR completes English (US) i18n support for the console frontend (console/ai-proxy-dashboard) by adding browser language auto-detection + a manual language toggle, and by extracting remaining hardcoded Chinese UI strings into i18n keys (with locale-aware formatting updates).
Changes:
- Added
i18next-browser-languagedetectorand configured i18n to detect language vialocalStorage→navigator, withzhfallback. - Replaced remaining hardcoded Chinese strings in key dashboard pages/components with i18n keys (including memoized,
t-parameterized factories for module-level constants like API docs endpoints/examples). - Updated date/number formatting and request sorting to use the active
i18n.languagelocale.
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| console/ai-proxy-dashboard/src/i18n/locales/zh.ts | Added new translation keys (login hero, combobox, pagination, cost formula labels, API docs, providers extras, etc.). |
| console/ai-proxy-dashboard/src/i18n/locales/en.ts | Added English equivalents for newly extracted UI strings and labels. |
| console/ai-proxy-dashboard/src/i18n/index.ts | Added browser language auto-detection with i18next-browser-languagedetector + persistence. |
| console/ai-proxy-dashboard/src/features/dashboard/utils.ts | Switched formatting/sorting and some metric labels to i18n-aware locale/strings. |
| console/ai-proxy-dashboard/src/features/dashboard/hooks/use-dashboard-data.ts | Added bilingual (ZH+EN) comment translations in touched sections. |
| console/ai-proxy-dashboard/src/features/dashboard/components/session-shell.tsx | Extracted login hero UI strings to i18n keys (incl. show/hide). |
| console/ai-proxy-dashboard/src/features/dashboard/components/routes-page.tsx | Localized “Rule N” label via i18n key. |
| console/ai-proxy-dashboard/src/features/dashboard/components/request-log-table.tsx | Added bilingual comment translations for column meaning notes. |
| console/ai-proxy-dashboard/src/features/dashboard/components/providers-page.tsx | Localized remaining UI strings (counts/placeholders/filters) and added bilingual comments. |
| console/ai-proxy-dashboard/src/features/dashboard/components/nav-bar.tsx | Localized subtitles and added a language toggle control. |
| console/ai-proxy-dashboard/src/features/dashboard/components/models-page.tsx | Added bilingual comment translation for a dialog note. |
| console/ai-proxy-dashboard/src/features/dashboard/components/logs-page.tsx | Added bilingual comment translation for debounce note. |
| console/ai-proxy-dashboard/src/features/dashboard/components/keys-page.tsx | Made date-time formatting locale-aware via active i18n.language. |
| console/ai-proxy-dashboard/src/features/dashboard/components/detail-view.tsx | Added bilingual comment translations for metric/tabs notes. |
| console/ai-proxy-dashboard/src/features/dashboard/components/api-docs-page.tsx | Localized all remaining UI strings; refactored endpoints/body examples into t-driven factories updated on language change. |
| console/ai-proxy-dashboard/src/features/dashboard/api.ts | Localized login failure fallback message via i18n. |
| console/ai-proxy-dashboard/src/components/ui/pagination.tsx | Localized pagination UI and accessibility labels. |
| console/ai-proxy-dashboard/src/components/ui/combobox.tsx | Localized default placeholders/empty-state strings via i18n. |
| console/ai-proxy-dashboard/package.json | Added i18next-browser-languagedetector dependency. |
| changelog/2026-07-29.md | Added changelog entry documenting the i18n work. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+8
to
+24
| // Auto-detect the browser/system language, remembering the user's choice in | ||
| // localStorage. Falls back to Chinese (zh) when detection is inconclusive. | ||
| i18n | ||
| .use(LanguageDetector) | ||
| .use(initReactI18next) | ||
| .init({ | ||
| resources: { zh: { translation: zh }, en: { translation: en } }, | ||
| fallbackLng: "zh", | ||
| supportedLngs: ["zh", "en"], | ||
| nonExplicitSupportedLngs: true, | ||
| interpolation: { escapeValue: false }, | ||
| detection: { | ||
| order: ["localStorage", "navigator"], | ||
| lookupLocalStorage: "lrs-console-lang", | ||
| caches: ["localStorage"], | ||
| }, | ||
| }) |
Author
|
@GoJam11 Please ignore/skip Copilot's suggestions; they suck to hell. I've tested it manually, and it works, but accepting Copilot's suggestions breaks CI, so I reverted that commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds full English (US) i18n support to the console frontend (
console/ai-proxy-dashboard). README.md/README.en.md language switchers and i18next/react-i18next setup already existed; this PR completes the remaining work:i18next-browser-languagedetector. Detection order islocalStorage→navigator, persisted under thelrs-console-langkey, falling back to Chinese (zh) when detection is inconclusive.zhandenviai18n.changeLanguage().api-docs-page.tsx,routes-page.tsx, andproviders-page.tsx. Module-level constants that previously held static Chinese text (e.g., API docs endpoint list/body examples) were converted into functions parameterized by the translation functiont, recomputed viauseMemowhenever the active language changes.formatTime,formatCount,keys-page'sformatDateTime, and the request-listlocaleComparesort now use the activei18n.languageinstead of a hardcodedzh-CNlocale.changelog/2026-07-29.mddocumenting this work.Screenshots
Agent-Logs-Url: https://github.com/erbanku/llmrelayservice/sessions/7458dbd5-b9cf-4680-8511-7a2e43a18e28
Co-authored-by: erbanku 79493862+erbanku@users.noreply.github.comAgent-Logs-Url: https://github.com/erbanku/llmrelayservice/sessions/7458dbd5-b9cf-4680-8511-7a2e43a18e28
Co-authored-by: erbanku 79493862+erbanku@users.noreply.github.com