A simple plugin that replaces translation key usages with imports from a file.
In these examples the JSON file containing the translations that are then
imported is assumed to be @tools/i18n-plugin/.cache/translations.i18n
.
For Next.js you can install the package and reference it directly from
next.config.js
module.exports = {
experimental: {
swcPlugins: [
[
"@galaxus/swc-plugin-translation-importer",
{ translationCache: "@tools/i18n-plugin/.cache/translations.i18n" },
],
],
},
};
If you use SWC standalone, you have to point it to the Wasm module by adding
something like the following to .swcrc
{
"jsc": {
"experimental": {
"plugins": [
[
"/path/to/swc_plugin_translation_importer.wasm",
{
"translationCache": "@tools/i18n-plugin/.cache/translations.i18n"
}
]
]
}
}
}
Get the Rust toolchain and the
right target with rustup target add wasm32-wasi
. Then you're just a npm run build
away and can find the result swc_plugin_translation_importer.wasm
.
To get the necessary tools, run npm install
if never done before & install
git-cliff.
On the release PR do
- Generate changelog with
git cliff --bump -o CHANGELOG.md
and update version number inCargo.toml
andpackage.json
On main
(after merge of the release PR) do
git tag vX.Y.Z
andgit push --tags
npm publish
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.