@bluecateng/l10n-cli

中文文档
0.3.0发布于 2026/08/14ISCES Module构建来源已验证近 30 天下载 1867

Command line utilities for l10n

原始使用文档
文档目录11 节
  1. Installation
  2. Configuration
  3. hashLength
  4. sourcePath
  5. module
  6. catalogPath
  7. locales
  8. Usage
  9. Extracting strings
  10. Building catalogs
  11. Usage as a file watcher in JetBrains IDEs (WebStorm/IDEA)

@bluecateng/l10n-cli

Command line utilities for l10n.

Upgrading from an older major version? See the migration guide.

Installation

npm i -D @bluecateng/l10n-cli

Configuration

Add an object with this format to package.json. All paths are relative to the directory where package.json is located.

"bc-l10n": {
  "hashLength": <number>,
  "sourcePath": <string>,
  "module": <string>,
  "catalogPath": <string>,
  "locales": <Array<string>>
}

hashLength

To save space in production the code only contains a hash of the original string. This field specifies the length to which the hashes will be truncated. It should be the minimum length which avoids clashes, clashes are validated at build time.

  • Required: yes
  • Example: 3

sourcePath

The path to the sources.

  • Required: no
  • Default: "src"

module

The path to the module which loads the strings (see @bluecateng/l10n-core).

  • Required: yes
  • Example: "src/l10n"

catalogPath

The path where the message catalog files will be created. It must contain the token "{locale}" which will be replaced with the corresponding locale. It must not contain an extension, the extension will be appended on generation.

  • Required: yes
  • Example: "src/l10n/{locale}"

locales

List of BCP-47 locale codes.

  • Required: no
  • Default: ["en"]
  • Example: ["en", "fr"]

Usage

Extracting strings

The command line can be used in two modes:

  • during development to extract strings from individual files for a single locale.
  • before committing to extract strings from all source files for all configured locales.

npx @bluecateng/l10n-cli [ -l <locale> ] [ <file-paths> ... ]

locale

The single locale code to update. If not specified, all the configured locales will be updated.

file-paths

The paths to the source files from which strings will be extracted. If not specified, all the source files will be scanned.

Building catalogs

Compiles the .po catalog for every configured locale into a .po.js module that can be imported directly (see @bluecateng/l10n-core).

npx @bluecateng/l10n-cli build <outDir>

outDir

The directory where the compiled .po.js files will be written. Each catalog is written at the path corresponding to its catalogPath, made relative to sourcePath and rooted at outDir.

  • Example: with sourcePath "src" and catalogPath "src/l10n/{locale}", the en catalog is written to <outDir>/l10n/en.po.js.

Usage as a file watcher in JetBrains IDEs (WebStorm/IDEA)

This configuration can be added under Settings > Tools > File Watchers.

PO file watcher configuration

版本与发布记录

@bluecateng/l10n-cli 共发布 8 个版本,首次发布于 2022/09/22;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.0latest2026/08/142 个月前
0.2.22026/04/096 个月前
0.2.12025/06/041.4 年前
0.2.02024/04/272 年前
0.1.82023/02/223 年前
0.1.72023/02/093 年前

关于 @bluecateng/l10n-cli 的常见问题

@bluecateng/l10n-cli 是什么?

Command line utilities for l10n

如何安装 @bluecateng/l10n-cli?

在项目目录运行 npm install @bluecateng/l10n-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 l10n-cli,可以用 npx l10n-cli 直接运行。

@bluecateng/l10n-cli 支持 TypeScript 吗?

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

@bluecateng/l10n-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bluecateng/l10n-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.18.0 || >=24.11.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bluecateng/l10n-cli 可以商用吗?

@bluecateng/l10n-cli 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bluecateng/l10n-cli 的下载量有多少?

根据 npm 官方下载统计,@bluecateng/l10n-cli 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,867 次,日均约 62 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bluecateng/l10n-cli 还在维护吗?

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