feat: Add internationalization (i18n) support for en and zh-cn#48
feat: Add internationalization (i18n) support for en and zh-cn#48wuzhiguocarter wants to merge 3 commits intoaranticlabs:mainfrom
Conversation
- 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>
fb02299 to
c08cd1d
Compare
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>
44bc132 to
1816e4f
Compare
|
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 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. |
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)
i18next,react-i18next,i18next-browser-languagedetectorsrc/admin/i18n/index.ts) with browser language auto-detection and localStorage persistencesrc/admin/i18n/locales/en.json(412 keys)src/admin/i18n/locales/zh-cn.json(412 keys)Phase 2: Widget (Preact)
src/widget/i18n/index.ts) — no external dependenciesPhase 3: Server
Key Features
How to Test
bun run typecheck— passes ✅bun run build— passes ✅Files Changed (29 files)