hyperlocalise run, and pass an ID-to-string
map to IntlProvider. This guide keeps the workflow in your repository.
For shared review in Platform, use the Platform React Intl tutorial.
Before you start
You need a React app withreact-intl, the Hyperlocalise CLI,
and an AI provider credential.
This example uses TypeScript, JSON imports, OpenAI, and Spanish as the target language.
1. Define messages with stable IDs
Createsrc/messages.ts:
2. Extract the source catalog
Run from your project root:.ts and .tsx files for defineMessage, defineMessages,
intl.formatMessage, and FormattedMessage. It does not extract arbitrary string
literals. See extract for ignore patterns and generated IDs.
3. Map the catalog to a target locale
Createi18n.yml:
OPENAI_API_KEY in your shell or an untracked .env.local file.
The CLI automatically recognizes the FormatJS catalog shape.
It translates defaultMessage and retains metadata.
4. Translate and check the result
lang/es-ES.json. A translated entry might look like this:
5. Load translations into React Intl
React Intl accepts strings or compiled message ASTs inIntlProvider.messages.
Convert this guide’s descriptor catalog to strings before passing it to the
provider. See the IntlProvider reference.
In src/app.tsx:
¡Hola, Ana!. Test the plural
message with count set to 1 and 2, and confirm the singular and plural text
in your generated catalog renders correctly.
This example assumes your TypeScript and bundler setup supports JSON imports.
Use your app’s locale loader when adding language switching.
Do I need to run pack?
No. The conversion above works with the translated catalog directly. If you want to strip descriptions from a separate build artifact, you can run:pack still retains defaultMessage objects for FormatJS
input. Apply the same conversion if you import the packed file. Keep the original
catalog available for translation context and review.

