feat: implement i18n with next-intl for Chinese Simplified and Traditional support #232
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.
Overview
This PR implements comprehensive internationalization (i18n) support for the RxChat application using
next-intl, adding Chinese Simplified and Chinese Traditional language support alongside English.Supported Languages
Key Changes
1. Infrastructure Setup
next-intlv4.3.9 for Next.js 15 App Router[locale]segment2. Translation System
Created comprehensive translation files for all three languages covering:
All translation files maintain consistent structure and keys across locales, stored in
locales/{locale}/common.json.3. Component Updates
Translated Components:
components/greeting.tsx- Dynamic welcome messagescomponents/suggested-actions.tsx- Localized AI prompt suggestionsapp/[locale]/(auth)/login/page.tsx- Full login page translationapp/[locale]/(auth)/register/page.tsx- Full registration page translationNew Components:
components/language-selector.tsx- Dropdown language switcher integrated into sidebar user navigation4. URL Structure
All routes now include locale prefix:
5. Navigation Helpers
Created locale-aware navigation helpers in
lib/i18n/routing.tsthat wrap Next.js navigation APIs:These ensure locale is maintained during navigation and redirects.
6. Import Path Updates
After restructuring the app directory, updated 50+ files with corrected import paths from:
@/app/(auth)/auth→@/app/[locale]/(auth)/auth@/app/(chat)/actions→@/app/[locale]/(chat)/actionsTesting
Unit Tests (17 new tests, all passing)
lib/i18n/config.spec.ts- Validates locale configurationlocales/locales.spec.ts- Ensures translation consistency across all localesCode Quality
Documentation
Added comprehensive documentation:
docs/i18n.md- Complete implementation guide with usage examples, best practices, and troubleshootingdocs/i18n-architecture.md- System architecture documentation with flow diagramsREADME.md- Updated with i18n feature informationUsage
Users can switch languages via the dropdown in the sidebar user menu:
Technical Implementation
Middleware Flow:
Configuration Files:
lib/i18n/config.ts- Locale definitions and nameslib/i18n/request.ts- next-intl request configurationlib/i18n/routing.ts- Routing configuration and navigation wrappersmiddleware.ts- Locale detection and auth handlingBreaking Changes
/en).Migration for developers:
next/linkandnext/navigationimports with@/lib/i18n/routingequivalentsNextIntlClientProviderFuture Enhancements
The i18n infrastructure is now in place to easily add more languages:
lib/i18n/config.tslocales/{locale}/common.jsonPotential additions: French, German, Japanese, Korean, Spanish, etc.
Screenshots
The language selector has been integrated into the existing sidebar user navigation menu, appearing above the theme toggle option. When clicked, it displays a dropdown with all available languages using both their native names and English labels.
Closes #[issue-number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
router.mcprouter.appnode generate.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.