Penulis:
    Dibuat:2026-06-13Terakhir diperbarui:2026-06-13

    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:

    bash
    npx intlayer init

    This 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 .po sync 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.