Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeep committed May 8, 2024
1 parent 12aea27 commit 29696be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,16 @@ import translate from '@kabeep/node-translate';

// Retry attempts for the translation request in case of failure (with a maximum of three requests)
translate('例子', { to: 'en', retry: 2, timeout: 100 }).catch((err) => {
// => ETIMEDOUT - One of the timeout limits was reached
// => ETIMEDOUT - The timeout limits was reached
// => ECONNRESET - The connection was forcibly closed
// => EADDRINUSE - Could not bind to any free port
// => ECONNREFUSED - The connection was refused by the server
// => EPIPE - The remote side of the stream being written has been closed
// => ENOTFOUND - Could not resolve the hostname to an IP address
// => ENETUNREACH - No internet connection
// => EAI_AGAIN - DNS lookup timed out
// => EPARSE - Failure of parse translation
// => EVALIDATION - Failure of iso code validation
// => EPARSE - Unexpected API response data
// => EVALIDATION - Illegal language code
console.log(err.message);
});
```
Expand All @@ -392,8 +392,7 @@ translate('例子', { to: 'en', retry: 2, timeout: 100 }).catch((err) => {
[View Case](example/iso.ts)

```javascript
import { LanguageCode } from 'iso-639-1';
import { iso6391X, LanguageOption } from '../src/index.js';
import { iso6391X, LanguageCode, LanguageOption } from '@kabeep/node-translate';

// => en
console.log(iso6391X.getCode('english'));
Expand Down
9 changes: 4 additions & 5 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,16 @@ import translate from '@kabeep/node-translate';

// 在翻译请求失败时进行重试尝试(此时最多三次请求)
translate('例子', { to: 'en', retry: 2, timeout: 100 }).catch((err) => {
// => ETIMEDOUT - 达到了其中一个超时限制
// => ETIMEDOUT - 达到了超时限制
// => ECONNRESET - 连接被强制关闭
// => EADDRINUSE - 无法绑定到任何空闲端口
// => ECONNREFUSED - 服务器拒绝了连接
// => EPIPE - 正在写入的流的远程端已关闭
// => ENOTFOUND - 无法将主机名解析为 IP 地址
// => ENETUNREACH - 没有网络连接
// => EAI_AGAIN - DNS 查询超时
// => EPARSE - 解析翻译失败
// => EVALIDATION - ISO 代码验证失败
// => EPARSE - 意料外的响应数据
// => EVALIDATION - 非法语言代码
console.log(err.message);
});
```
Expand All @@ -389,8 +389,7 @@ translate('例子', { to: 'en', retry: 2, timeout: 100 }).catch((err) => {
[查看用例](example/iso.ts)

```javascript
import { LanguageCode } from 'iso-639-1';
import { iso6391X, LanguageOption } from '../src/index.js';
import { iso6391X, LanguageCode, LanguageOption } from '@kabeep/node-translate';

// => en
console.log(iso6391X.getCode('english'));
Expand Down
3 changes: 1 addition & 2 deletions example/iso.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LanguageCode } from 'iso-639-1';
import { iso6391X, LanguageOption } from '../src/index.js';
import { iso6391X, type LanguageCode, type LanguageOption } from '../src/index.js';

// => en
console.log(iso6391X.getCode('english') as string);
Expand Down
4 changes: 2 additions & 2 deletions src/shared/translate-error-codes.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ResponseErrorCodes } from './response-error-codes.type.js';

export type TranslateErrorCodes =
| 'EPARSE' // Failure of parse translation
| 'EVALIDATION' // Failure of iso code validation
| 'EPARSE' // Unexpected API response data
| 'EVALIDATION' // Illegal language code
| ResponseErrorCodes;

0 comments on commit 29696be

Please sign in to comment.