Posez votre question et obtenez un résumé du document en referencant cette page et le Provider AI de votre choix
Historique des versions
- "Init history"v9.0.013/06/2026
Le contenu de cette page a été traduit à l'aide d'une IA.
Voir la dernière version du contenu original en anglaisIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Migrate from Lingui to Intlayer
If your project currently relies on Lingui's macro-based compilation, transitioning to Intlayer allows you to maintain your powerful macro workflows while backing them natively with Intlayer's JSON compilation strategy.
What to do
To begin, initialize Intlayer in your project:
Copier le code dans le presse-papiers
npx intlayer initThis creates your intlayer.config.ts. Ensure you retain @lingui/babel-plugin-lingui-macro / @lingui/swc-plugin in your build step to run before the Intlayer compiler. Then, use the bundler plugin alias to route @lingui/core and @lingui/react to @intlayer/lingui.
What it does under the hood
Lingui utilizes macros (like t`Hello ${name}` and <Trans>) which are compiled into runtime calls like i18n._(id, values).
Under the hood:
- Macros: They compile precisely as they did before, ensuring no disruption in your source syntax.
- Runtime translation: The aliased
i18n._()uses Intlayer dictionaries. Both explicitly named IDs and hashed IDs are fully mapped using Intlayer's.posync plugins to aggregate and prune keys securely. - ICU capabilities: Support for pluralization, selection, and ICU variants remains robust due to Intlayer's unified ICU parser, ensuring identical rendering outputs.