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