Skip to content

feat: Add internationalization (i18n) support for en and zh-cn#48

Open
wuzhiguocarter wants to merge 3 commits intoaranticlabs:mainfrom
wuzhiguocarter:feat/i18n-support
Open

feat: Add internationalization (i18n) support for en and zh-cn#48
wuzhiguocarter wants to merge 3 commits intoaranticlabs:mainfrom
wuzhiguocarter:feat/i18n-support

Conversation

@wuzhiguocarter
Copy link
Copy Markdown

@wuzhiguocarter wuzhiguocarter commented May 7, 2026

Summary

This PR adds full internationalization (i18n) support to BugPin for English (en) and Simplified Chinese (zh-cn).

What was done

Phase 1: Admin Console (React)

  • Installed i18next, react-i18next, i18next-browser-languagedetector
  • Created i18n configuration (src/admin/i18n/index.ts) with browser language auto-detection and localStorage persistence
  • Created comprehensive translation files:
    • src/admin/i18n/locales/en.json (412 keys)
    • src/admin/i18n/locales/zh-cn.json (412 keys)
  • Translated pages: Login, Dashboard, Reports, ReportDetail, Projects
  • Translated components: AppSidebar, NavMain, NavUser, Layout, ErrorBoundary, UpdateBanner, AboutDialog, Footer, AppearanceDialog, LanguageSwitcher
  • Added Language Switcher component in the sidebar footer (globe icon dropdown)
  • Organized translations into logical groups: common, auth, dashboard, reports, reportDetail, projects, settings, etc.

Phase 2: Widget (Preact)

  • Created lightweight i18n helper (src/widget/i18n/index.ts) — no external dependencies
  • Created widget translation files for en and zh-cn
  • Language syncs with admin via shared localStorage key

Phase 3: Server

  • Left server-side email templates in English (complex HTML templates)
  • Added TODO comments for future server-side i18n

Key Features

  • 🌐 Auto-detects browser language
  • 💾 Persists language choice in localStorage
  • 🔄 Language switcher in sidebar
  • 📦 Lazy-loaded translations
  • ✅ No breaking changes — all existing functionality preserved

How to Test

  1. bun run typecheck — passes ✅
  2. bun run build — passes ✅
  3. Switch language using the globe icon in sidebar footer
  4. Verify all UI strings change between English and Chinese
  5. Refresh page — language preference is persisted

Files Changed (29 files)

  • 6 new files (i18n config + 4 locale files + LanguageSwitcher)
  • 23 modified files (pages, components, sidebar)

- Admin Console: react-i18next with 368 translation keys across 22 namespaces
- Widget: lightweight custom i18n helper (zero dependencies)
- Language auto-detection from browser/navigator.language
- Language preference persisted in localStorage
- Full Chinese (Simplified) translations for all user-facing strings
- Add language switcher in sidebar appearance dialog

Admin Console changes:
- Install i18next, react-i18next, i18next-browser-languagedetector
- Create i18n config with language detection and fallback
- Extract all hardcoded strings from 30+ components and pages
- Add en.json and zh-cn.json translation files (368 keys each)

Widget changes:
- Create lightweight i18n module (no external deps for Preact)
- Internationalize WidgetDialog, ScreenshotManager, ScreenCaptureConsentDialog
- Add en.json and zh-cn.json translation files

Verified: typecheck passes, build:admin and build:widget succeed
Signed-off-by: wuzhiguo <1600682324@qq.com>
Signed-off-by: wuzhiguo <1600682324@qq.com>
- Fix critical i18n namespace resolution bug by adding nsSeparator: false,
  fallbackNS and defaultNS to i18n config (fixes all globalsettings pages)
- Add ~600 new translation keys across 20+ namespaces in en/zh-cn locales
- Convert static arrays with hardcoded strings to getter functions for
  lazy translation evaluation (STATS, NAV_SECTIONS, template types)
- Convert Zod schemas with hardcoded error messages to factory functions
- Cover all 5 batches: core pages, globalsettings, components, TestWidgetPage, widget

Signed-off-by: wuzhiguo <1600682324@qq.com>
@RahulRaj97
Copy link
Copy Markdown
Collaborator

Hi @wuzhiguocarter , thank you so much for putting this PR together. We really appreciate the time and effort you put into adding i18n support and preparing the English and Simplified Chinese translations.

For context, translations are already being worked on from the original feature request here: #8

The current implementation is on our 8-translations feature branch: https://github.com/aranticlabs/bugpin/tree/8-translations

The main Chinese widget locale file is here: https://github.com/aranticlabs/bugpin/blob/8-translations/src/widget/i18n/locales/zh.ts

Because of that, we probably won’t merge this PR directly as-is, since we don’t want to maintain two separate i18n implementations or duplicate the same work.

That said, your contribution is still very valuable. Since you have strong context around the Chinese translations, would you be open to reviewing the Simplified Chinese copy on our existing branch? Feedback on wording, tone, and anything that feels unnatural would be extremely helpful before we merge the translation feature.

Thanks again for taking the initiative here. We’d really appreciate your feedback and would be happy to keep collaborating with you on translations and future improvements to BugPin.

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.

2 participants