Mmohebifar

i18n-pro-codemod

I18nize your codebase

transformationmigration
Public
3 executions
2 stars
How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

i18n-pro-codemod

Automatically extract hardcoded strings and internationalize your React codebase

This pro codemod intelligently identifies hardcoded text in your React components and transforms them into properly internationalized code using modern i18n libraries like next-intl, react-i18next, or react-intl.

🚀 Features

  • AI-powered: Uses advanced AI to generate meaningful translation keys and handle complex string patterns
  • Multi-library support: Works with next-intl, react-i18next, and react-intl
  • Smart Sharding: Handles large codebases by intelligently splitting work across teams/directories
  • Automated PR creation: Creates pull requests with proper reviews and formatting
  • Message catalog management: Automatically creates and updates translation files
  • Context-aware: Preserves code structure and handles complex JSX patterns

🔧 How It Works

The codemod scans your React/TypeScript files for hardcoded strings in JSX elements and transforms them into internationalized code:

Before

tsx

After (next-intl)

tsx

After (react-intl)

tsx

Generated Message Catalog (messages/en.json)

json

🔥 Advanced Interpolation Examples

The codemod handles complex scenarios with ICU syntax, including variables, pluralization, and rich text:

Variable Interpolation (next-intl)

Before:

tsx

After:

tsx

Generated Catalog:

json

Variable Interpolation (react-intl)

tsx

Complex Conditional Logic

Before:

tsx

After:

tsx

Generated Catalog:

json

Rich Text with Components (next-intl)

Before:

tsx

After:

tsx

Generated Catalog:

json

Rich Text with Components (react-intl)

The same ICU messages above can be rendered with react-intl like this:

tsx

🎯 What Gets Transformed

  • Hardcoded text in JSX elements (<div>text</div>)
  • String literals in JSX attributes
  • Complex nested text structures
  • Preserves existing component logic and structure

⚙️ Configuration Options

  • Library: Choose between next-intl, react-i18next, or react-intl
  • Sharding Method: Process large codebases by codeowner or directory
  • Catalog File Selection: Default structure or custom Zap package organization
  • AI Review: Automated code review and quality checks
  • Custom Scripts: Pre/post-run hooks for additional processing

💼 Professional Version

This is a professional codemod that requires a license for commercial use.

To access this codemod, please contact us for:

  • Enterprise licensing
  • Custom configuration support
  • Priority support and updates
  • Team training and onboarding
Before

This is one example from the codemod's test cases. The codemod may handle many more cases.

Ready to contribute?

Build your own codemod and share it with the community.