Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init history"v9.8.523/11/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf 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
Migrating from Lingui to Intlayer
Why migrate from Lingui to Intlayer?
Lingui loads one compiled catalogue per locale, holding every message of the app. Intlayer splits content per dictionary and only ships what each page uses, which reduces your bundle and page sizes by up to 50%.
Intlayer dictionaries are fully typed, and can be co-located with the components that use them. No extract / compile step to remember: dictionaries are built by the bundler plugin.
Co-located content reduces the context needed by LLMs. Intlayer ships a CLI to test for missing translations, an LSP, an MCP server and agent skills.
Translate missing messages in your CI/CD pipeline with the LLM of your choice, or in the background with the web platform.
Intlayer provides a self-hosted visual editor and a full CMS so translators and copywriters can edit content in real time.
To understand where these libraries come from, read the history of JavaScript i18n.
Migration strategies
- Compat adapter (recommended for existing apps): Install
@intlayer/lingui. It exposes the same API as@lingui/coreand@lingui/react(i18n,setupI18n,I18nProvider,useLingui,Trans) and serves messages from Intlayer dictionaries. Your macros (t`…`,<Trans>,msg,plural) keep compiling exactly as before. - Full migration: Gradually replace Lingui calls with
useIntlayerand.content.tsfiles co-located with your components.
Table of Contents
Quick migration
Install Dependencies
bashCopy codeCopy the code to the clipboard
The
--interactiveflag is optional. Useintlayer-cli initif you're an AI agent.The command detects your environment and installs the required packages, for example:
bashCopy codeCopy the code to the clipboard
Keep
@lingui/core,@lingui/reactand your macro plugin (@lingui/babel-plugin-lingui-macroor@lingui/swc-plugin) installed. The macros still run, and the Lingui packages provide the TypeScript types.Configure Intlayer
Intlayer reads your Lingui catalogues as the source of truth. With Lingui's default layout (
src/locales/{locale}/messages.po), point thesyncPOplugin at them:intlayer.config.tsCopy codeCopy the code to the clipboard
import { Locales, type IntlayerConfig } from "intlayer"; import { syncPO } from "@intlayer/sync-po-plugin"; const config: IntlayerConfig = { internationalization: { locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], defaultLocale: Locales.ENGLISH, }, plugins: [ syncPO({ // ./src/locales/en/messages.po → dictionary `messages` source: ({ key, locale }) => `./src/locales/${locale}/${key}.po`, }), ], }; export default config;With
@lingui/format-json, usesyncJSONwith the ICU format:intlayer.config.tsCopy codeCopy the code to the clipboard
Use explicit message ids (
t({ id: "hero.title", message: "Welcome" })or<Trans id="hero.title">). Ids generated from the source text are not resolved against the catalogues.Replace the Lingui Vite plugin
Swap
@lingui/vite-pluginfor@intlayer/lingui/plugin. The binding stayslingui(): it runs the Intlayer build and aliases@lingui/coreand@lingui/reactto@intlayer/lingui, so no source file changes are needed.vite.config.tsCopy codeCopy the code to the clipboard
import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { lingui } from "@intlayer/lingui/plugin"; // was "@lingui/vite-plugin" export default defineConfig({ plugins: [ react({ babel: { plugins: ["@lingui/babel-plugin-lingui-macro"] }, }), lingui(), ], });Keep the macro plugin in the React plugin (Babel or
@lingui/swc-plugin), so macros are compiled toi18n._()calls before Intlayer resolves them.
Your components keep working unchanged:
Copy the code to the clipboard
Switching locale still goes through i18n.activate(locale), which updates every useLingui() consumer.
Complete migration
Remove runtime catalogue loading
OptionalMessages now come from Intlayer dictionaries compiled at build time. Calls to
i18n.load()/i18n.loadAndActivate()only serve as a fallback and print a warning in development. Replace them withi18n.activate(locale)and drop thelingui compilestep. Keeplingui extractto collect new message ids.Explicit import renaming (optional)
OptionalThe Vite plugin already handles aliasing. To make the dependency explicit:
Show all table contentOpen the table in a modal to view all data content clearly
Before After import { i18n } from '@lingui/core'import { i18n } from '@intlayer/lingui'import { setupI18n } from '@lingui/core'import { setupI18n } from '@intlayer/lingui'import { I18nProvider } from '@lingui/react'import { I18nProvider } from '@intlayer/lingui'import { useLingui, Trans } from '@lingui/react'import { useLingui, Trans } from '@intlayer/lingui'Move content to .content.ts files
OptionalNew components can use native Intlayer content, side by side with existing Lingui calls:
src/hero.content.tsCopy codeCopy the code to the clipboard
src/Hero.tsxCopy codeCopy the code to the clipboard
Enable AI-powered translation
OptionalbashCopy codeCopy the code to the clipboard
Filled translations are written back to your Lingui catalogues. See the CLI documentation for AI configuration.
What you can delete after migration
Open the table in a modal to view all data content clearly
| File / pattern | Why it's no longer needed |
|---|---|
i18n.load() / dynamic catalogue imports | Dictionaries are compiled and loaded by Intlayer. |
lingui compile and compiled .js catalogues | Intlayer builds dictionaries from your catalogues directly. |
@lingui/vite-plugin | Replaced by lingui() from @intlayer/lingui/plugin. |
Configure TypeScript
Include the generated types in your tsconfig.json:
Copy the code to the clipboard
Git Configuration
Copy the code to the clipboard
