Đặt câu hỏi và nhận tóm tắt tài liệu bằng cách tham chiếu trang này và nhà cung cấp AI bạn chọn
Lịch sử phiên bản
- "Init history"v9.0.013/6/2026
Nội dung của trang này đã được dịch bằng AI.
Xem phiên bản mới nhất của nội dung gốc bằng tiếng AnhIf 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:
Sao chép mã vào clipboard
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.