| name | internationalization-i18n |
| description | Implements multi-language support using i18next, gettext, or Intl API with translation workflows and RTL support. Use when building multilingual applications, handling date/currency formatting, or supporting right-to-left languages. |
| license | MIT |
Internationalization (i18n)
Implement multi-language support with proper translation management and formatting.
i18next Setup (React)
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
interpolation: { escapeValue: false },
resources: {
en: { translation: { welcome: 'Welcome, {{name}}!' } },
es: { translation: { welcome: '¡Bienvenido, {{name}}!' } }
}
});
const { t } = useTranslation();
<h1>{t('welcome', { name: 'John' })}</h1>
Pluralization
{
"items": "{{count}} item",
"items_plural": "{{count}} items",
"items_zero": "No items"
}
t('items', { count: 0 })
t('items', { count: 1 })
t('items', { count: 5 })
Date/Number Formatting
new Intl.DateTimeFormat('de-DE', {
dateStyle: 'long',
timeStyle: 'short'
}).format(new Date());
new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(1234.56);
new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
.format(-1, 'day');
RTL Support
.container {
margin-inline-start: 1rem;
padding-inline-end: 1rem;
}
html[dir="rtl"] .icon {
transform: scaleX(-1);
}
Additional Frameworks
See references/frameworks.md for:
- React-Intl (Format.js) complete implementation
- Python gettext with Flask/Babel
- RTL language support patterns
- ICU Message Format examples
Best Practices
- Extract all user-facing strings
- Use ICU message format for complex translations
- Test with pseudo-localization
- Support RTL from the start
- Never concatenate translated strings
- Use professional translators for production