Skip to content

chore: upgrade i18n-js from 3.x to 4.x #426

Description

@hb2708

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

  1. Install new version:
    yarn add i18n-js@latest
    yarn add --dev @types/i18n-js@latest
  2. 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';
  3. Update all t() calls — ensure they use the new instance:
    // Before: I18n.t('key')
    // After:  i18n.t('key')
  4. Review pluralization — v4 has a different pluralization system
  5. Search codebase for all imports: grep -r "i18n-js" app/
  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions