feat(i18n): add English + Portuguese (pt-BR) UI translation#57
Open
quantmind-br wants to merge 2 commits into
Open
feat(i18n): add English + Portuguese (pt-BR) UI translation#57quantmind-br wants to merge 2 commits into
quantmind-br wants to merge 2 commits into
Conversation
- 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>
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 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.pyresponse messages andpool_core.pystatus 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.mdalready 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 azh.jsonand set Chinese as the defaultfallbackLng— let me know.Changes
Frontend (
frontend/)i18next,react-i18next,i18next-browser-languagedetectorsrc/i18n/index.ts— initialization withlocalStorage→navigator→htmlTagdetection chainsrc/i18n/locales/en.json,src/i18n/locales/pt-BR.json— ~150 translation keys eachsrc/main.tsx— imports./i18nonce at bootsrc/layouts/AdminLayout.tsx— sidebar menu items uset(); added language switcher footersrc/pages/{Dashboard,AccountsPage,TokensPage,TestPage,ImagePage,SettingsPage}.tsx— replaced all hardcoded strings witht()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.py—status_mapreturns 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 errorsenandpt-BRresource bundles/settings, switch language via sidebar dropdown — all visible strings reflect the chosen locale🤖 Generated with Claude Code