A comprehensive guide and working example for implementing internationalization (i18n) and localization in React applications. Features step-by-step implementations of language switching, number/date formatting, dynamic translations, and RTL support using react-i18next and Tailwind CSS.
- π Multiple language support (English, Arabic)
- π RTL layout support
- π Tailwind CSS integration
- β‘ Performance optimization techniques
- π§ͺ Form validation with Zod
- π¦ Organized translation structure
Each feature is implemented in its own branch for easier learning:
base
: Basic i18next configurationrtl-support
: RTL layout implementationperformance
: Performance optimizationpersistence-events
: Persisting the preference languageformatting
: Formatting dates and numbersnamespaces
: Implementing namespaces
- React
- TypeScript
- Tailwind CSS
- i18next
- react-i18next
- Zod
- react-hook-form
- Clone the repository:
git clone https://github.com/othmanekahtal/react-i18n-practical-guide.git
- Install dependencies:
pnpm install
- Run the development server:
pnpm dev
src/
βββ locales/ # Translation files
β βββ en/
β β βββ common.json
β β βββ auth.json
β β βββ validation.json
β βββ ar/
βββ components/ # React components
βββ i18n.ts # i18next configuration
βββ App.tsx # Main application
This project includes configuration for the i18n Ally extension. To use it:
- Install the "i18n Ally" extension
- English is configured as the source language
- Enjoy real-time translation previews and management
Feel free to contribute to this project. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
x - @othmane_kahtal
Linkedin - @othmane kahtal
hashnode - @othmane kahtal
Blog Link: https://blog.othmane.me/building-multilingual-react-apps-practical-guide-to-i18next-and-rtl-support