Skip to main content
This tutorial connects React Intl message descriptors to Hyperlocalise Cloud. You will extract a stable FormatJS catalog, protect ICU structure, review translations, and load the returned catalogs in React.

Prerequisites

You need:
  • a React app using react-intl;
  • the Hyperlocalise CLI;
  • a Cloud project with en-US as source and fr-FR and de-DE as targets; and
  • HYPERLOCALISE_API_KEY and HYPERLOCALISE_PROJECT_ID in your environment.
The example uses this layout:

1. Define stable messages

Keep user-facing copy in descriptors with explicit IDs and translator descriptions:
Render the descriptor with values:
ICU keeps all plural branches in one message. Translators may change the prose, but they must preserve the count argument and valid plural syntax.

2. Map the catalogs

Create i18n.yml:
Hyperlocalise recognizes strict FormatJS JSON. It translates defaultMessage and preserves message IDs, descriptions, and other metadata.

3. Extract the source catalog

Run:
The catalog contains one entry per descriptor:
Commit lang/en-US.json with the code change. This makes catalog drift visible in pull requests and gives Cloud a file to sync.
If you omit an id, hl extract generates a FormatJS-compatible hash. Explicit IDs produce easier diffs and more recognizable entries in review.

4. Prevent extract drift in CI

Re-run extraction in the source pull request and fail when it changes the committed catalog:
This gate catches a changed defaultMessage without an updated catalog. The dry run confirms that the catalog maps to the expected Cloud project.

5. Push and review the catalog

After the source pull request merges:
In Cloud, start generation through a Source upload automation or New Request. In Content Editor, review:
  • every required plural category for the target locale;
  • unchanged argument names such as {count};
  • glossary terms in each plural branch;
  • descriptions and screenshots for ambiguous labels; and
  • length in the real interface.
Approve the translations before pulling them back.

6. Pull and validate translations

Run:
hl check catches missing target messages, placeholder mismatches, and icu_shape_mismatch errors. Exercise plural branches in tests:
Use values that cover =0, one, and other. Add locale-specific cases when a language has more plural categories.

7. Pack catalogs for runtime

FormatJS catalogs contain review metadata. Pack target catalogs in place:
The packed entry retains defaultMessage and removes its description:
Convert this shape to the Record<string, string> expected by IntlProvider:
Open a translation pull request containing the pulled and packed files. Run unit, build, and visual tests before merging it.

Troubleshooting

CI reports catalog drift

Run hl extract with the same paths and ignore patterns as CI, then commit lang/en-US.json.

icu_shape_mismatch appears

Compare argument names and ICU branches with the source. Fix the target in Cloud and approve the new revision. Do not suppress a real ICU mismatch.

React shows MISSING_TRANSLATION

Confirm the message ID exists in the pulled catalog, hl pack ran, and the app loads the target locale file passed to IntlProvider.

Next