@babelize/cli

中文文档
1.3.17发布于 2026/11/02Apache-2.0ES Module近 30 天下载 4152

Official CLI for the Babelize AI-powered i18n platform

原始使用文档
文档目录15 节
  1. Install
  2. Quick start
  3. With your own LLM key, or in CI
  4. Quick Start (platform)
  5. Commands
  6. Shell Completion
  7. Configuration
  8. Environment Variables
  9. CI / Non-Interactive Mode
  10. Exit Codes
  11. JSON Mode
  12. Telemetry
  13. Update Notifications
  14. Troubleshooting
  15. Links

@babelize/cli

Babelize CLI — AI-powered i18n platform for managing translations from your terminal.

Install

npm install -g @babelize/cli

Quick start

In your project's folder:

npx babelize        # or: npx @babelize/cli

It checks git (offering git init and a first commit, and warning about uncommitted changes), finds your framework, i18n library and source language on your machine, signs you in if needed (GitHub or Google in the browser, or email and password), asks which languages you want (remembered in .babelize/config.json), then writes locale files and i18n code for review with git diff. Signed in, no API key is needed: translation is billed in Babelize credits, and the summary shows how many were used.

When it's done, add a language switcher (ready-made ones at https://elements.babelize.co, or build your own). Run npx babelize again after changes: only new or changed text is translated. For pull requests instead, connect the repo at https://app.babelize.co or run babelize run start.

Without a terminal, pass the languages: babelize start --to fr,de --yes. (The interactive command menu is now babelize shell.)

With your own LLM key, or in CI

babelize translate is the same local translation with flags instead of questions. Use your own LLM key (no account needed), your signed-in session, or a Babelize API key:

export ANTHROPIC_API_KEY=sk-ant-...   # or OPENAI_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, OPENROUTER_API_KEY
npx babelize translate --to fr,de,ja
git diff

Or use Babelize-hosted translation: create an API key at https://app.babelize.co/api-keys (free tier included), then

export BABELIZE_API_KEY=bblz_sk_...
npx babelize translate --to fr,de,ja
  • Frameworks: React, Next.js (App Router), Django and static HTML are supported. Vue and React Native (Expo and bare) are in beta.
  • Key: the first LLM key found in the order above is used; with none, BABELIZE_API_KEY selects Babelize-hosted translation, and with no key at all your signed-in session does (strings only, never code; billed in Babelize credits). Pick another with --provider (babelize for hosted), or a different model with --model.
  • Output: --json prints the QA report, which is also written to .babelize/local/report.json (--report <path> moves it). A run where some keys failed exits 6 unless --allow-partial.
  • Safety: it needs a git repo with a clean working tree (--force overrides). It works on a temporary copy and touches nothing if the run fails. --dry-run prints the diff without writing.
  • Re-runs: commit .babelize/local/babelize-lock.json and later runs only translate new or changed strings.

Full guide: https://docs.babelize.co/cli/translate

Quick Start (platform)

# Log in to your Babelize account
babelize auth login

# Initialize a new project
babelize init

# Start a translation run
babelize run start

Commands

CommandDescription
(no command) / startTranslate the project in this folder, step by step (git, sign-in, languages)
translate --to <locales>Translate this repo locally: signed in, your own LLM key, or BABELIZE_API_KEY (writes to the working tree)
check [path]QA the locale files (missing keys, placeholders, ICU, plurals); exits 1 on errors, for CI
shellThe interactive command menu
initInitialize a new Babelize project
auth login / signup / logout / whoamiAuthentication management
auth reset-passwordSend a password reset email
auth provider-tokensManage OAuth provider tokens (GitHub, etc.)
statusCheck API health and your account status
scan [directory]Scan a local directory for hardcoded translatable strings
projectsCRUD, sync, insights, metadata, download, brand-voice, archive
run start / status / analyzeTranslation pipeline engine (start supports --no-poll, --no-pr, --json)
babelsView translation job history
prGitHub PR integration
billingPlans, usage, invoices
subscriptionsList plans, show the default plan and your current plan
checkoutPurchase a plan
languagesSystem and project-level language management, ISO ↔ FLORES-200 code conversion
membersTeam member management
tmTranslation memory (owner-scoped, shared across your projects: view, add, update, export as TMX, clear)
glossaryTranslation glossary (list, add, update, delete, import, export)
api-keys byokBYOK provider keys (OpenAI, Anthropic, Groq, etc.)
api-keys babelizeBabelize API keys (bblz_sk_ prefix for MCP/external access)
commentsTranslation comments and discussions
notificationsNotification inbox
analyticsUsage history, activity logs, audit logs
accountMFA, sessions, account deletion
privacyGDPR data export and erasure
adminPlatform administration (owner only)
invitationsTeam invitations
rolesRole management
usersUser listing

Run babelize <command> --help for subcommand details.

Shell Completion

Generate bash or zsh completion scripts:

babelize completion bash > /usr/local/etc/bash_completion.d/babelize
babelize completion zsh > /usr/local/share/zsh/site-functions/_babelize

The script dynamically reflects all registered commands at generation time.

Configuration

Credentials and preferences are stored at:

  • macOS: ~/Library/Preferences/@babelize/cli-nodejs/config.json
  • Linux: ~/.config/@babelize/cli-nodejs/config.json
  • Windows: %APPDATA%\@babelize\cli-nodejs\Config\config.json

The API URL resolves in this order:

  • --api-url flag — per-command override
  • BABELIZE_API_URL env var — e.g. http://localhost:3001/api for local dev
  • Stored config — the URL saved by babelize auth login --api-url <url> or the "Self-hosted" login choice (localhost URLs included). A URL is only stored when you ask for it.
  • Default: https://api.babelize.co/api

Environment Variables

VariableDescription
BABELIZE_API_URLOverride API URL
BABELIZE_TOKENAuth token (alternative to babelize auth login or --token) — recommended for CI. Also used for signed-in translation
BABELIZE_NON_INTERACTIVEForce non-interactive mode (1 or true)
CIWhen set (not "false"), the CLI never prompts — missing flags exit with a usage error
NO_COLORDisable colored output (any non-empty value)
ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, OPENROUTER_API_KEYYour LLM key for babelize translate (first one set wins; --provider to choose)
BABELIZE_API_KEYBabelize API key (bblz_sk_…) for hosted translation in babelize start / babelize translate when no LLM key is set
BABELIZE_TELEMETRY0 turns off anonymous usage data (DO_NOT_TRACK=1 works too). See Telemetry

CI / Non-Interactive Mode

The CLI is CI-safe. Set CI=true (most pipelines do automatically), set BABELIZE_NON_INTERACTIVE=1, or pass --non-interactive / --yes, and the CLI will never block on a prompt. --yes also answers "yes" to confirmations such as deletes; without it, a confirmation in non-interactive mode fails with exit code 2:

CI=true babelize run start -p <project-id> -l es,fr --no-poll --json

In non-interactive mode, missing required flags exit with 2 (usage) and an actionable message instead of prompting. Closed stdin (non-TTY) is also treated as non-interactive.

Authenticate in CI with a token rather than a stored session:

export BABELIZE_TOKEN=bblz_sk_xxxxxxxx

For local translation in CI, set BABELIZE_API_KEY (or your own LLM key) and run npx babelize start --to fr,de --yes.

See the CI/CD docs for a full GitHub Actions recipe.

Exit Codes

CodeMeaningWhen it happens
0SuccessCommand completed
1Internal errorUnexpected failure
2Usage errorUnknown command, bad flag, missing or invalid argument (e.g. a malformed ID), or a prompt that cannot be answered in non-interactive mode
3Auth errorNot logged in, session expired, login failed, token rejected
4Config errorNo way to translate (no key and not signed in), unsupported project, no locale files for check
5Network errorAPI unreachable, rate limited, DNS failure, timeout
6API errorServer returned 4xx/5xx; a run that failed (run start, run status --watch)
128CancelledInteractive prompt cancelled, or a run that was cancelled before it finished

A cancelled prompt exits 128, never 0 — so a pipeline step can't silently pass when required input is missing.

Scripts can use these codes for conditional logic:

babelize run start --no-poll || exit_code=$?
if [ $exit_code -eq 3 ]; then
  babelize auth login
fi

JSON Mode

Append --json to a command for machine-readable JSON output. Coverage is per subcommand: where a subcommand doesn't implement it, --json is ignored and the usual human-readable output is printed (e.g. babelize projects list --json returns JSON, but some members and notifications subactions do not).

With --json, spinners and other progress output never touch stdout (errors and notices go to stderr), so babelize --json auth whoami | jq works. When stdout is not a terminal, spinners are replaced by plain lines on stderr.

Telemetry

The CLI sends anonymous usage data: the command, CLI/Node/OS version, framework, translator type, target locales, counts and whether the run succeeded. Never your code, strings, file names or account details. babelize check and --provider pseudo send nothing. A notice is printed the first time.

Turn it off with babelize telemetry disable, BABELIZE_TELEMETRY=0 or DO_NOT_TRACK=1. Details: docs.babelize.co/cli/telemetry.

Update Notifications

The CLI checks npm registry for new versions once per session (non-blocking). To update:

npm update -g @babelize/cli

Troubleshooting

ProblemSolution
Not authenticatedRun babelize auth login
Directory not found on scanEnsure the path exists and is a directory
EPERM on installUse sudo npm install -g @babelize/cli
Completion not workingEnsure the script is sourced: source /usr/local/etc/bash_completion.d/babelize
Rate limitedWait 60 seconds and retry
BABELIZE_API_URL not honoredEnsure the env var is set before running the command

版本与发布记录

@babelize/cli 共发布 41 个版本,首次发布于 2026/07/02;过去 12 个月发布了 41 个版本。

版本发布日期距今
1.3.17latest2026/11/025 天前
1.3.162026/11/016 天前
1.3.152026/11/016 天前
1.3.142026/11/016 天前
1.3.132026/11/016 天前
1.3.122026/11/016 天前

关于 @babelize/cli 的常见问题

@babelize/cli 是什么?

Official CLI for the Babelize AI-powered i18n platform

如何安装 @babelize/cli?

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

@babelize/cli 支持 TypeScript 吗?

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

@babelize/cli 支持 ESM 还是 CommonJS?

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

@babelize/cli 需要什么版本的 Node.js?

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

@babelize/cli 可以商用吗?

@babelize/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@babelize/cli 的下载量有多少?

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

@babelize/cli 还在维护吗?

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