This project shows how to use the Rspack JavaScript bundler with Lingui JS to provide i18n for a React application (TypeScript).
npm install
to install dependenciesnpm run dev
to run the development server.npm run build
to build the application.
- Wrap any messages requiring translation in
<Trans>
or a related macro. npm run extract
to generate message catalogs insrc/locales/{locale}/messages
.- Translate any new messages in the catalogs.
npm run compile
to create runtime catalogs.
-
rspack.config.js
specifies thebuiltin:swc-loader
should transcompile all.tsx
files using the Lingui SWC plugin, ensuring transcompilation of Lingui Macros like<Trans>
into their respective React components. When using Lingui SWC plugin, ensure version compatibility with@rspack/core
. Refer to the compatibility guide for selecting the appropriate plugin version. -
lingui.config.ts
specifies the available locales, defaults, and paths where the message catalogs are stored.
- This blog post shows a step-by-step guide to set up LinguiJS with React.
- Official documentation for React setup with LinguiJS. This repo closely follows the example from the official docs.