Skip to content

feat(i18n): add English + Portuguese (pt-BR) UI translation#57

Open
quantmind-br wants to merge 2 commits into
YuJunZhiXue:mainfrom
quantmind-br:feat/i18n-en-pt-br
Open

feat(i18n): add English + Portuguese (pt-BR) UI translation#57
quantmind-br wants to merge 2 commits into
YuJunZhiXue:mainfrom
quantmind-br:feat/i18n-en-pt-br

Conversation

@quantmind-br

Copy link
Copy Markdown

Summary

Adds full internationalization (i18n) support to the admin WebUI using react-i18next, with English and Português (Brasil) locale bundles. A language switcher dropdown is added to the bottom of the sidebar; the choice is persisted in localStorage (qwen2api_lang).

Also translates user-facing strings in two backend files (admin.py response messages and pool_core.py status map) so non-Chinese-reading admins see English text in toasts and API responses.

The original Chinese strings are not preserved as a bundle in this PR — the consensus on the original Issue tracker / README.en.md already targets English-speaking deployers, and the UI now defaults to English while supporting pt-BR. If the project wants Chinese kept as a bundle, I'm happy to add a zh.json and set Chinese as the default fallbackLng — let me know.

Changes

Frontend (frontend/)

  • New deps: i18next, react-i18next, i18next-browser-languagedetector
  • src/i18n/index.ts — initialization with localStoragenavigatorhtmlTag detection chain
  • src/i18n/locales/en.json, src/i18n/locales/pt-BR.json — ~150 translation keys each
  • src/main.tsx — imports ./i18n once at boot
  • src/layouts/AdminLayout.tsx — sidebar menu items use t(); added language switcher footer
  • src/pages/{Dashboard,AccountsPage,TokensPage,TestPage,ImagePage,SettingsPage}.tsx — replaced all hardcoded strings with t() calls, using {{var}} interpolation for dynamic values (account counts, error details, etc.)

Backend (backend/)

  • api/admin.py — 6 user-facing error/success messages translated (registration, activation, validation flows)
  • core/account_pool/pool_core.pystatus_map returns English status labels (the frontend now handles localization independently, so the API can return canonical English)

Test plan

  • cd frontend && npm install && npm run build — succeeds, 1786 modules transformed, no errors
  • Vite bundle contains both en and pt-BR resource bundles
  • Reviewer: open /settings, switch language via sidebar dropdown — all visible strings reflect the chosen locale
  • Reviewer: trigger toast messages (save key, generate API key, verify account) — toast text matches the selected language
  • Reviewer: admin error paths return English strings from the backend

🤖 Generated with Claude Code

quantmind-br and others added 2 commits May 19, 2026 02:27
- Add react-i18next infrastructure with browser language detection
- Replace hardcoded Chinese strings across AdminLayout + 6 pages
- Add language switcher dropdown in the sidebar (persisted in localStorage)
- Translate user-facing strings in backend admin.py and pool_core status_map
- Default language: English; falls back from browser detection

Locale bundles:
- en.json: English (default)
- pt-BR.json: Português (Brasil)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Restore original Chinese strings as a `zh` resource bundle (parity with
  pre-i18n version of the UI).
- Enable `nonExplicitSupportedLngs: true` so browser locales like `zh-CN`,
  `zh-TW`, `pt-PT`, `en-US` map cleanly to the available bundles.
- Sidebar language switcher now exposes English / Português (BR) / 中文.
- Default behavior: detector chain (localStorage → navigator → htmlTag)
  with English as fallback, so each visitor sees their own browser language
  when first opening the panel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant