Skip to content

Commit

Permalink
📝 docs: improve Usage section for better onboarding experience (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinshin86 authored Dec 2, 2024
1 parent 7fa79f2 commit 09ce889
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/lobe-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,33 @@ npm install -g @lobehub/i18n-cli

## 🤯 Usage

### Step 1: Initialize Configuration
To initialize the Lobe i18n configuration, run the following command:

```shell
$ lobe-i18n -o # or use the full flag --option
```

### Step 2: Run Translation Commands

This command will guide you through creating a configuration file step by step.

Alternatively, you can manually create a configuration file in one of the formats supported by [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig) (see [Configuration](#configuration) below).

Here's an example of a configuration file (`.i18nrc.js`):
This example demonstrates how to generate `locales/zh_CN.json` and `locales/ja_JP.json` automatically based on `locales/en_US.json`.

```javascript
const { defineConfig } = require('@lobehub/i18n-cli');

module.exports = defineConfig({
entry: 'locales/en_US.json',
entryLocale: 'en_US',
output: 'locales',
outputLocales: ['zh_CN', 'ja_JP'],
});
```

> \[!IMPORTANT]\
> To use AI auto-generation, you need to fill in the [OpenAI Token](https://platform.openai.com/account/api-keys) in the settings.
Expand Down
22 changes: 22 additions & 0 deletions packages/lobe-i18n/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,34 @@ npm install -g @lobehub/i18n-cli

## 🤯 使用

### 第一步:初始化配置

要初始化配置 Lobe i8n,请运行以下命令:

```shell
$ lobe-i18n -o # 或使用完整标志 --option
```

### 第二步:运行翻译命令

此命令将引导您逐步创建配置文件。

或者,您可以手动创建配置文件,支持的格式请参考 [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig) (详见 [Configuration](#configuration))。

以下是一个配置文件示例(`.i18nrc.js`):
此示例展示了如何基于 `locales/en_US.json` 自动生成 `locales/zh_CN.json``locales/ja_JP.json`

```javascript
const { defineConfig } = require('@lobehub/i18n-cli');

module.exports = defineConfig({
entry: 'locales/en_US.json',
entryLocale: 'en_US',
output: 'locales',
outputLocales: ['zh_CN', 'ja_JP'],
});
```

> \[!IMPORTANT]\
> 要使用 AI 自动生成,需要在设置中填写 [OpenAI 令牌](https://platform.openai.com/account/api-keys)
Expand Down

0 comments on commit 09ce889

Please sign in to comment.