Getting Started

Parlai CLI is a powerful tool that automates the setup and management of internationalization (i18n) in React applications. With just a few commands, you can extract hardcoded strings, transform your components, and even generate AI-powered translations.

Installation

npm install -g @parlai/cli

Quick Start

  1. Set up i18n in your project
    parlai setup
  2. Extract strings from your components
    parlai extract ./src
  3. Transform components to use i18n
    parlai transform ./src

Workflow Example

yarn global add @parlai/cli
cd your-react-app
parlai setup
parlai extract ./src
parlai transform ./src
parlai translate --api-key=your-openai-api-key --target fr es

Notes

  • The setup command creates a locales directory for your translation files.
  • Run extract before transform to ensure all strings are captured.
  • The transform command requires locales/en.json to exist (created by extract).
  • Components using translations may be made async to support dynamic loading.
  • Backup your code before running the transform command.