Summary
Upgrade i18n-js from 3.5.1 to 4.x. Version 4 is a complete rewrite with a new class-based API that affects all translation calls across the app.
Current → Target
| Package |
Current |
Latest |
i18n-js |
3.5.1 |
4.5.2 |
@types/i18n-js |
3.0.2 |
4.0.1 |
Why Upgrade
- v3 is no longer maintained
- v4 has improved TypeScript support, better pluralization, and a cleaner API
- Fixes known issues with locale fallback behavior
Migration Steps
- Install new version:
yarn add i18n-js@latest
yarn add --dev @types/i18n-js@latest
- Update initialization — v4 uses a class-based API:
// Before (v3)
import I18n from 'i18n-js';
I18n.translations = { en: { ... }, fr: { ... } };
I18n.locale = 'en';
// After (v4)
import { I18n } from 'i18n-js';
const i18n = new I18n({ en: { ... }, fr: { ... } });
i18n.locale = 'en';
- Update all
t() calls — ensure they use the new instance:
// Before: I18n.t('key')
// After: i18n.t('key')
- Review pluralization — v4 has a different pluralization system
- Search codebase for all imports:
grep -r "i18n-js" app/
- Run
yarn ci to verify
Files Likely Affected
- Translation initialization file (locale setup)
- Every component/screen that calls
I18n.t() or imports from i18n-js
- Any custom locale/fallback configuration
References
Summary
Upgrade
i18n-jsfrom 3.5.1 to 4.x. Version 4 is a complete rewrite with a new class-based API that affects all translation calls across the app.Current → Target
i18n-js@types/i18n-jsWhy Upgrade
Migration Steps
t()calls — ensure they use the new instance:grep -r "i18n-js" app/yarn cito verifyFiles Likely Affected
I18n.t()or imports fromi18n-jsReferences