@easyi18n/cli v0.2.0
@easyi18n/cli
Usage
Installation
# Using npm
npm install -g @easyi18n/cli
# Using yarn
yarn global add @easyi18n/cli
tr
# Using pnpm
pnpm add -g @easyi18n/cli
Quick Start
easyi18n --init
After initialization, two configuration files will be created. Please refer to the configuration instructions below to set up your API Key and other settings. If you encounter any issues during initialization, you can manually configure according to the configuration instructions.
Configuration
- Set up your environment variables in
.env
file:
OPENAI_API_KEY=your_api_key_here
OPENAI_API_HOST=your_openai_api_host_here
Set up your easyi18n config file:
@easyi18n/cli uses cosmiconfig for configuration. You can configure it in several ways:
(recommended)
easyi18n.config.js
,easyi18n.config.ts
,easyi18n.config.mjs
, oreasyi18n.config.cjs
fileeasyi18n
property inpackage.json
.easyi18nrc
file in JSON or YAML format.easyi18nrc.json
,.easyi18nrc.yaml
,.easyi18nrc.yml
,.easyi18nrc.js
,.easyi18nrc.ts
,.easyi18nrc.mjs
, or.easyi18nrc.cjs
file
Configuration Example
easyi18n.config.ts
:
import { defineConfig } from "@easyi18n/cli";
// For detailed field descriptions, please refer to the type definitions
export default defineConfig({
localeDir: "src/locales",
entry: "src/locales/en",
format: "json",
concurrency: 5,
llmConfig: {
model: "gpt-4o",
temperature: 0.3,
},
});
.easyi18nrc.json
:
{
"localeDir": "src/locales/toml",
"entry": "src/locales/toml/en",
"format": "toml"
}
llmConfig
is optional, if you don't set it, @easyi18n/cli will use the default configuration by llm provider.
Translation Commands
# Translate to a specific locale
easyi18n -l zh-CN
# Translate a specific file
easyi18n -l zh-CN -f path/to/file
# Translate a specific key in a file
easyi18n -l zh-CN -f path/to/file -k key.to.translate
# Translate to all configured locales
easyi18n -l all
Command Options
-l, --locale
: Target locale (e.g., 'zh-CN', 'ja', 'ko') or 'all' for all locales-f, --file
: (Optional) Target file to translate-k, --key
: (Optional) Specific key to translate in the target file
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
12 months ago
12 months ago