Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lobe i18n] Improve Usage section for better onboarding experience #157

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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