Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeep committed Aug 30, 2024
1 parent 59431ba commit d60a62c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ translate(text, options)
.catch(console.error);
```

| Parameter | Type | Optional | Default | Description |
|-------------------|------------------------------------|----------|----------|----------------------------------------------------------------------------------------------------------------|
| `text` | `string` | No | - | Source text, phrase or word. |
| `options` | `TranslateOptions` | - | - | The options for translating. |
| `options.from` | `LanguageCode`, `auto` or `string` | Yes | `'auto'` | The language name/ISO 639-1 code to translate from. If none is given, it will auto-detect the source language. |
| `options.to` | `LanguageCode`, `auto` or `string` | Yes | `'auto'` | The language name/ISO 639-1 code to translate to. If none is given, it will translate to English. |
| `options.raw` | `boolean` | Yes | `false` | If `true`, it will return the raw output that was received from Google Translation Api. |
| `options.timeout` | `number` | Yes | `30_000` | Timeout duration for the translation request in milliseconds. |
| `options.retry` | `number` | Yes | `0` | Retry attempts for the translation request in case of failure. |
| Parameter | Type | Optional | Default | Description |
|-------------------|------------------------------------|----------|----------|-----------------------------------------------------------------------------------------------------------------------|
| `text` | `string` | No | - | Source text, phrase or word. |
| `options` | `TranslateOptions` | - | - | The options for translating. |
| `options.from` | `LanguageCode`, `auto` or `string` | Yes | `'auto'` | The language name/ISO 639-1 code to translate from. If none is given, it will auto-detect the source language. |
| `options.to` | `LanguageCode`, `auto` or `string` | Yes | `'auto'` | The language name/ISO 639-1 code to translate to. If none is given, it will translate to native environment language. |
| `options.raw` | `boolean` | Yes | `false` | If `true`, it will return the raw output that was received from Google Translation Api. |
| `options.timeout` | `number` | Yes | `30_000` | Timeout duration for the translation request in milliseconds. |
| `options.retry` | `number` | Yes | `0` | Retry attempts for the translation request in case of failure. |

#### Returns: `Promise<TranslationOption>`

Expand Down Expand Up @@ -293,9 +293,9 @@ import translate from '@kabeep/node-translate';
// Output example sentence of the source word
translate('example', { to: 'zh' }).then(res => {
// => [
// "it is vitally important that parents should set an <b>example</b>",
// "she followed her brother's <b>example</b> and deserted her family",
// "it's a good <b>example</b> of how European action can produce results",
// "it is vitally important that parents should set an [example]",
// "she followed her brother's [example] and deserted her family",
// "it's a good [example] of how European action can produce results",
// ]
console.log(res.from.sentences);
});
Expand Down
28 changes: 14 additions & 14 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ translate(text, options)
.catch(console.error);
```

| 参数 | 类型 | 可选 | 默认值 | 描述 |
|-------------------|--------------------|-----|----------|-----------------------------------------|
| `text` | `string` || - | 源文本、短语或单词。 |
| `options` | `TranslateOptions` | - | - | 翻译选项。 |
| `options.from` | `LanguageCode` || `'auto'` | 要从中翻译的语言名称/ISO 639-1代码。如果未指定,则会自动检测源语言。 |
| `options.to` | `LanguageCode` || `'auto'` | 要翻译到的语言名称/ISO 639-1代码。如果未指定,则会翻译为英语。 |
| `options.raw` | `boolean` || `false` | 如果为 `true`,将返回从谷歌翻译 API 接收到的原始输出。 |
| `options.timeout` | `number` | Yes | `30_000` | 翻译请求的超时持续时间(以毫秒为单位)。 |
| `options.retry` | `number` | Yes | `0` | 如果失败,请重试翻译请求。 |
| 参数 | 类型 | 可选 | 默认值 | 描述 |
|-------------------|--------------------|-----|----------|------------------------------------------|
| `text` | `string` || - | 源文本、短语或单词。 |
| `options` | `TranslateOptions` | - | - | 翻译选项。 |
| `options.from` | `LanguageCode` || `'auto'` | 要从中翻译的语言名称/ISO 639-1代码。如果未指定,则会自动检测源语言。 |
| `options.to` | `LanguageCode` || `'auto'` | 要翻译到的语言名称/ISO 639-1代码。如果未指定,则会翻译为本机环境语言。 |
| `options.raw` | `boolean` || `false` | 如果为 `true`,将返回从谷歌翻译 API 接收到的原始输出。 |
| `options.timeout` | `number` | Yes | `30_000` | 翻译请求的超时持续时间(以毫秒为单位)。 |
| `options.retry` | `number` | Yes | `0` | 如果失败,重试翻译请求的次数。 |

#### 返回: `Promise<TranslationOption>`

Expand Down Expand Up @@ -215,12 +215,12 @@ translate('例子', { to: 'en' }).then(res => {

#### 使用语言名和大小写修正

[View Case](example/language.ts)
[查看用例](example/language.ts)

```javascript
import translate from '@kabeep/node-translate';

// Language name and capitalized correction
// 使用语言名称并自动更正大小写
translate('例子', { to: 'ENGlish' }).then(res => {
// => example
console.log(res.text);
Expand Down Expand Up @@ -290,9 +290,9 @@ import translate from '@kabeep/node-translate';
// 输出源词的例句
translate('example', { to: 'zh' }).then(res => {
// => [
// "it is vitally important that parents should set an <b>example</b>",
// "she followed her brother's <b>example</b> and deserted her family",
// "it's a good <b>example</b> of how European action can produce results",
// "it is vitally important that parents should set an [example]",
// "she followed her brother's [example] and deserted her family",
// "it's a good [example] of how European action can produce results",
// ]
console.log(res.from.sentences);
});
Expand Down

0 comments on commit d60a62c

Please sign in to comment.