@galaxus/swc-plugin-translation-importer
v2.0.0
Published
Replaces translation key usages with imports from file
Downloads
73
Readme
swc-plugin-translation-importer
A simple plugin that replaces translation key usages with imports from a file.
Usage
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"
}
]
]
}
}
}
Build
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
.
Release
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
License
Licensed under either of
at your option.
Contribution
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.