Skip to content

feat(i18n): add full English (US) support with browser auto-detect - #11

Open
erbanku wants to merge 4 commits into
GoJam11:mainfrom
erbanku:main
Open

feat(i18n): add full English (US) support with browser auto-detect#11
erbanku wants to merge 4 commits into
GoJam11:mainfrom
erbanku:main

Conversation

@erbanku

@erbanku erbanku commented Jul 29, 2026

Copy link
Copy Markdown

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:

  • Browser language auto-detection: added i18next-browser-languagedetector. Detection order is localStoragenavigator, 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.

Screenshots

image image image

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

Claude AI and others added 4 commits July 29, 2026 03:09
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.
@erbanku
erbanku marked this pull request as ready for review July 29, 2026 03:41
Copilot AI review requested due to automatic review settings July 29, 2026 03:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-languagedetector and configured i18n to detect language via localStoragenavigator, with zh fallback.
  • 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.language locale.

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"],
},
})
@erbanku

erbanku commented Jul 29, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants