@galaxus/swc-plugin-translation-importer

中文文档
7.0.1发布于 2026/10/21(MIT OR Apache-2.0)CommonJS零依赖构建来源已验证近 30 天下载 2.1万

Replaces translation key usages with imports from file

原始使用文档
文档目录5 节
  1. Usage
  2. Build
  3. Release
  4. License
  5. Contribution

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-wasip1. 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

  1. Generate changelog with git cliff --bump -o CHANGELOG.md and update version number in Cargo.toml and package.json

On main (after merge of the release PR) do

  1. git tag vX.Y.Z and git push --tags
  2. 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.

版本与发布记录

@galaxus/swc-plugin-translation-importer 共发布 18 个版本,首次发布于 2022/07/15;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
7.0.1latest2026/10/2125 天前
7.0.02026/10/2026 天前
6.0.02026/02/039 个月前
5.0.02025/11/051 年前
4.0.02025/07/181.3 年前
3.0.02025/03/041.7 年前

其他发布通道:preview → 0.6.0-preview.1。

关于 @galaxus/swc-plugin-translation-importer 的常见问题

@galaxus/swc-plugin-translation-importer 是什么?

Replaces translation key usages with imports from file

如何安装 @galaxus/swc-plugin-translation-importer?

在项目目录运行 npm install @galaxus/swc-plugin-translation-importer,或使用 pnpm add / yarn add / bun add。

@galaxus/swc-plugin-translation-importer 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/galaxus__swc-plugin-translation-importer 是否存在。

@galaxus/swc-plugin-translation-importer 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@galaxus/swc-plugin-translation-importer 可以商用吗?

@galaxus/swc-plugin-translation-importer 使用 (MIT OR Apache-2.0) 许可。可在 MIT、Apache-2.0 中任选其一遵守。选择 MIT 时,宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@galaxus/swc-plugin-translation-importer 的下载量有多少?

根据 npm 官方下载统计,@galaxus/swc-plugin-translation-importer 在 2026/10/16 – 2026/11/14 这 30 天内被下载 20,989 次,日均约 700 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@galaxus/swc-plugin-translation-importer 还在维护吗?

最新版本 7.0.1 发布于 2026/10/21(25 天前);至今共发布 18 个版本,其中过去 12 个月发布了 3 个;首次发布于 2022/07/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。