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
- Set up i18n in your project
parlai setup
- Extract strings from your components
parlai extract ./src
- 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 alocales
directory for your translation files. - Run
extract
beforetransform
to ensure all strings are captured. - The
transform
command requireslocales/en.json
to exist (created byextract
). - Components using translations may be made async to support dynamic loading.
- Backup your code before running the
transform
command.