@yxw007/translate 0.5.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -37
  3. package/README_zh-CN.md +84 -32
  4. package/dist/browser/index.cjs +2262 -3004
  5. package/dist/browser/index.esm.js +2262 -2998
  6. package/dist/browser/index.esm.min.js +28 -1
  7. package/dist/browser/index.min.cjs +28 -1
  8. package/dist/browser/index.umd.js +2392 -3130
  9. package/dist/browser/index.umd.min.js +28 -1
  10. package/dist/engines/amazon.d.ts +7 -0
  11. package/dist/engines/azure.d.ts +9 -0
  12. package/dist/engines/baidu.d.ts +6 -0
  13. package/dist/engines/deepl.d.ts +88 -0
  14. package/dist/engines/google.d.ts +3 -0
  15. package/dist/engines/helper.d.ts +2 -0
  16. package/dist/engines/index.d.ts +16 -0
  17. package/dist/engines/openai.d.ts +8 -0
  18. package/dist/engines/tencent.d.ts +7 -0
  19. package/dist/engines/yandex.d.ts +5 -0
  20. package/dist/index.d.ts +15 -3048
  21. package/dist/language/check/baidu.d.ts +9 -0
  22. package/dist/language/check/index.d.ts +775 -0
  23. package/dist/language/engines/amazon.d.ts +158 -0
  24. package/dist/language/engines/azure.d.ts +278 -0
  25. package/dist/language/engines/baidu.d.ts +424 -0
  26. package/dist/language/engines/deepl.d.ts +77 -0
  27. package/dist/language/engines/google.d.ts +494 -0
  28. package/dist/language/engines/index.d.ts +1973 -0
  29. package/dist/language/engines/openai.d.ts +494 -0
  30. package/dist/language/engines/tencent.d.ts +44 -0
  31. package/dist/language/index.d.ts +8 -0
  32. package/dist/language/origin/deepl.d.ts +36 -0
  33. package/dist/language/origin/index.d.ts +998 -0
  34. package/dist/language/origin/tencent.d.ts +22 -0
  35. package/dist/language/target/amazon.d.ts +78 -0
  36. package/dist/language/target/azure.d.ts +138 -0
  37. package/dist/language/target/baidu.d.ts +211 -0
  38. package/dist/language/target/deepl.d.ts +39 -0
  39. package/dist/language/target/google.d.ts +246 -0
  40. package/dist/language/target/index.d.ts +1000 -0
  41. package/dist/language/target/tencent.d.ts +21 -0
  42. package/dist/node/index.cjs +2260 -2972
  43. package/dist/node/index.js +2259 -2967
  44. package/dist/node/index.min.cjs +28 -1
  45. package/dist/node/index.min.js +28 -1
  46. package/dist/package.json +113 -122
  47. package/dist/types/index.d.ts +56 -0
  48. package/dist/types/typescript.d.ts +1 -0
  49. package/dist/utils/cache.d.ts +15 -0
  50. package/dist/utils/check.d.ts +2 -0
  51. package/dist/utils/constant.d.ts +2 -0
  52. package/dist/utils/index.d.ts +6 -0
  53. package/dist/utils/logger.d.ts +6 -0
  54. package/dist/utils/node.d.ts +2 -0
  55. package/dist/utils/path.d.ts +1 -0
  56. package/dist/utils/utils.d.ts +7 -0
  57. package/package.json +14 -23
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Potter.yan
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Potter.yan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -9,6 +9,7 @@ English | [简体中文](./README_zh-CN.md)
9
9
  ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/yxw007/translate/ci.yml)
10
10
 
11
11
  ## ❓ Why do I need translate?
12
+
12
13
  1. a lot of translation tool libraries on the market, basically not very well-maintained
13
14
  2. not written by ts, not friendly enough when using the prompts
14
15
  3. single function, does not support batch translation Or only support a translation engine
@@ -17,6 +18,7 @@ English | [简体中文](./README_zh-CN.md)
17
18
  > Note: Translate helps you to solve all the above problems, and will expand more in the future!
18
19
 
19
20
  ## ✨ Features
21
+
20
22
  - 🌐 **Multi-environment support**: Node environment, browser environment
21
23
  - ✨ **Easy to use**: provides a concise API, you can easily help you to translate
22
24
  - 🌍 **Multi-translation engine support**: Google, Azure Translate, Amazon Translate, Deepl, Baidu, OpenAI, etc. (will expand more in the future)
@@ -26,6 +28,8 @@ English | [简体中文](./README_zh-CN.md)
26
28
 
27
29
  > **Special reminder: although the library has supported the use of the browser environment, but please only use the google engine translation (google does not need key), the use of other translation engine need to configure the key, the use of the front-end will lead to key leakage, do not do it**
28
30
 
31
+ > Browser bundles exclude Node-only helpers such as filesystem utilities. Keep browser usage focused on engines that are safe to expose client-side.
32
+
29
33
  ## 💻Translation engines, integration cases
30
34
 
31
35
  | Name | Support | Description |
@@ -39,6 +43,40 @@ English | [简体中文](./README_zh-CN.md)
39
43
  | tencent | ✔ | Commissioned and ready for use |
40
44
  | yandex | | I have not tuned in as I do not have a bank account supported by the platform (help from those who are in a position to do so is welcome and appreciated) |
41
45
 
46
+ ## 🛠 Development
47
+
48
+ This project now uses `rolldown`, `oxlint`, and `oxfmt` instead of `rollup`, `eslint`, and `prettier`.
49
+
50
+ ```bash
51
+ pnpm build
52
+ pnpm lint
53
+ pnpm lint:fix
54
+ pnpm format
55
+ pnpm format:check
56
+ pnpm test
57
+ ```
58
+
59
+ - `pnpm build`: builds Node and browser bundles with `rolldown`, then emits `.d.ts` files with TypeScript.
60
+ - `pnpm lint`: runs `oxlint` and `oxfmt --check`.
61
+ - `pnpm lint:fix`: applies `oxlint --fix` and formats files with `oxfmt`.
62
+ - `pnpm format`: formats the repository with `oxfmt`.
63
+ - `pnpm test`: runs stable offline-safe tests.
64
+
65
+ Integration tests that require real network access and third-party credentials are disabled by default. To run them manually, set `RUN_INTEGRATION_TESTS=true` before running `pnpm test`.
66
+
67
+ - Bash
68
+
69
+ ```bash
70
+ RUN_INTEGRATION_TESTS=true pnpm test
71
+ ```
72
+
73
+ - PowerShell
74
+
75
+ ```powershell
76
+ $env:RUN_INTEGRATION_TESTS = "true"
77
+ pnpm test
78
+ ```
79
+
42
80
  ## 🚀 Install
43
81
 
44
82
  - npm
@@ -64,16 +102,19 @@ English | [简体中文](./README_zh-CN.md)
64
102
  ### Node
65
103
 
66
104
  - ESM
105
+
67
106
  ```typescript
68
- import { translator, engines } from "@yxw007/translate"
107
+ import { translator, engines } from "@yxw007/translate";
69
108
  ```
70
109
 
71
110
  - Commonjs
111
+
72
112
  ```typescript
73
- const { translator, engines } = required("@yxw007/translate")
113
+ const { translator, engines } = required("@yxw007/translate");
74
114
  ```
75
115
 
76
116
  - Translation examples
117
+
77
118
  ```typescript
78
119
  translator.addEngine(engines.google);
79
120
  const res1 = await translator.translate("hello", { from: "en", to: "zh" });
@@ -84,18 +125,22 @@ English | [简体中文](./README_zh-CN.md)
84
125
  ```
85
126
 
86
127
  Output results
128
+
87
129
  ```bash
88
130
  ['你好']
89
131
  ["你好", "好的"]
90
132
  ```
133
+
91
134
  - Language detection examples
135
+
92
136
  ```typescript
93
137
  translator.addEngine(engines.google);
94
- const res1 = await translator.checkLanguage("hello", { engine:"google" });
138
+ const res1 = await translator.checkLanguage("hello", { engine: "google" });
95
139
  console.log(res1);
96
-
97
140
  ```
141
+
98
142
  Output results
143
+
99
144
  ```bash
100
145
  en
101
146
  ```
@@ -105,6 +150,7 @@ English | [简体中文](./README_zh-CN.md)
105
150
  use jsDelivr CDN
106
151
 
107
152
  - `development`
153
+
108
154
  ```html
109
155
  <script src="https://cdn.jsdelivr.net/npm/@yxw007/translate@0.0.7/dist/browser/index.umd.js"></script>
110
156
  ```
@@ -141,7 +187,6 @@ use jsDelivr CDN
141
187
 
142
188
  ```
143
189
 
144
-
145
190
  ## 📚 API
146
191
 
147
192
  ### Translator
@@ -195,7 +240,7 @@ type Engine = {
195
240
 
196
241
  #### `translate`
197
242
 
198
- You can pass a text or pass a text array, which will return a translated ```Promise<string[]>```
243
+ You can pass a text or pass a text array, which will return a translated `Promise<string[]>`
199
244
 
200
245
  ```typescript
201
246
  translate<T extends Engines>(text: string | string[], options: TranslateOptions<T>)
@@ -206,8 +251,8 @@ translate<T extends Engines>(text: string | string[], options: TranslateOptions<
206
251
  Read the language list for the specified engine.
207
252
 
208
253
  ```typescript
209
- translator.getFromLanguages("google")
210
- translator.getToLanguages("google")
254
+ translator.getFromLanguages("google");
255
+ translator.getToLanguages("google");
211
256
  ```
212
257
 
213
258
  #### TranslateOptions
@@ -217,7 +262,7 @@ export interface TranslateOptions {
217
262
  from?: FromLanguage<T>;
218
263
  to: ToLanguage<T>;
219
264
  engine?: Engines;
220
- /**
265
+ /**
221
266
  * Cache time in milliseconds
222
267
  */
223
268
  cache_time?: number;
@@ -297,11 +342,10 @@ interface AzureEngineOption extends BaseEngineOption {
297
342
 
298
343
  - Relative document:[rest-api-guide](https://learn.microsoft.com/zh-cn/azure/ai-services/translator/reference/rest-api-guide?WT.mc_id=Portal-Microsoft_Azure_ProjectOxford)
299
344
 
300
-
301
345
  #### AmazonEngineOption
302
346
 
303
347
  ```typescript
304
- interface AmazonEngineOption extends BaseEngineOption{
348
+ interface AmazonEngineOption extends BaseEngineOption {
305
349
  region: string;
306
350
  accessKeyId: string;
307
351
  secretAccessKey: string;
@@ -384,34 +428,34 @@ export type OpenAIModel = (typeof OPEN_AI_MODELS)[number];
384
428
 
385
429
  ```typescript
386
430
  export interface TencentEngineOption extends BaseEngineOption {
387
- secretId: string;
388
- secretKey: string;
389
- region?: string;
431
+ secretId: string;
432
+ secretKey: string;
433
+ region?: string;
390
434
  }
391
435
  ```
392
436
 
393
437
  > Description: Option Param Please obtain it from the corresponding platform.
438
+
394
439
  - Related documentation:https://console.cloud.tencent.com/cam/capi
395
440
 
396
441
  - Region Configuration table
397
- | 地域 | 取值 |
442
+ | 地域 | 取值 |
398
443
  | ---------------------- | ---------------- |
399
- | 亚太东南(曼谷) | ap-bangkok |
400
- | 华北地区(北京) | ap-beijing |
401
- | 西南地区(成都) | ap-chengdu |
402
- | 西南地区(重庆) | ap-chongqing |
403
- | 华南地区(广州) | ap-guangzhou |
404
- | 港澳台地区(中国香港) | ap-hongkong |
405
- | 亚太东北(首尔) | ap-seoul |
406
- | 华东地区(上海) | ap-shanghai |
407
- | 华东地区(上海金融) | ap-shanghai-fsi |
408
- | 华南地区(深圳金融) | ap-shenzhen-fsi |
409
- | 亚太东南(新加坡) | ap-singapore |
410
- | 亚太东北(东京) | ap-tokyo |
411
- | 欧洲地区(法兰克福) | eu-frankfurt |
412
- | 美国东部(弗吉尼亚) | na-ashburn |
413
- | 美国西部(硅谷) | na-siliconvalley |
414
-
444
+ | 亚太东南(曼谷) | ap-bangkok |
445
+ | 华北地区(北京) | ap-beijing |
446
+ | 西南地区(成都) | ap-chengdu |
447
+ | 西南地区(重庆) | ap-chongqing |
448
+ | 华南地区(广州) | ap-guangzhou |
449
+ | 港澳台地区(中国香港) | ap-hongkong |
450
+ | 亚太东北(首尔) | ap-seoul |
451
+ | 华东地区(上海) | ap-shanghai |
452
+ | 华东地区(上海金融) | ap-shanghai-fsi |
453
+ | 华南地区(深圳金融) | ap-shenzhen-fsi |
454
+ | 亚太东南(新加坡) | ap-singapore |
455
+ | 亚太东北(东京) | ap-tokyo |
456
+ | 欧洲地区(法兰克福) | eu-frankfurt |
457
+ | 美国东部(弗吉尼亚) | na-ashburn |
458
+ | 美国西部(硅谷) | na-siliconvalley |
415
459
 
416
460
  ## 🤝 Contribute
417
461
 
@@ -424,8 +468,8 @@ export interface TencentEngineOption extends BaseEngineOption {
424
468
  ```
425
469
 
426
470
  - Add new Engine
427
-
428
471
  - Add a new platform ENGINE plugin
472
+
429
473
  ```typescript
430
474
  export interface XXEngineOption extends BaseEngineOption {
431
475
  key: string;
@@ -436,7 +480,7 @@ export interface TencentEngineOption extends BaseEngineOption {
436
480
  const base = "https://translate.yandex.net/api/v1.5/tr.json/translate";
437
481
  return {
438
482
  name: "yandex",
439
- async checkLanguage<T extends Engines>(text: string): Promise<string> {
483
+ async checkLanguage<T extends Engines>(text: string): Promise<string> {
440
484
  //TODO: This can be done with translate, in which case the target language configuration is reused.
441
485
  },
442
486
  async translate<T extends Engines>(text: string | string[], opts: EngineTranslateOptions<T>) {
@@ -457,7 +501,8 @@ export interface TencentEngineOption extends BaseEngineOption {
457
501
  };
458
502
  }
459
503
  ```
460
- - Add the plugin to Engines(Location:```/src/engines/index.ts```)
504
+
505
+ - Add the plugin to Engines(Location:`/src/engines/index.ts`)
461
506
 
462
507
  ```typescript
463
508
  import { xx } from "./xx";
@@ -468,9 +513,10 @@ export interface TencentEngineOption extends BaseEngineOption {
468
513
  baidu,
469
514
  deepl,
470
515
  openai,
471
- xx
516
+ xx,
472
517
  } as const;
473
518
  ```
519
+
474
520
  - Add the origin language configuration supported by the engine
475
521
 
476
522
  ```typescript
@@ -525,8 +571,10 @@ export interface TencentEngineOption extends BaseEngineOption {
525
571
  ...
526
572
  xxx: ValuesOf<typeof xxx>;
527
573
  };
574
+ ```
528
575
 
529
576
  - Build
577
+
530
578
  ```bash
531
579
  pnpm build
532
580
  ```
@@ -538,8 +586,8 @@ export interface TencentEngineOption extends BaseEngineOption {
538
586
 
539
587
  > **Tips: At present, the library can be used normally. Welcome everyone to experience. If you have any questions and suggestions, you can mention the feedback to me.If you are interested, you are welcome to join, let us improve this tool together. Help to click star ⭐, let more people know this tool, thank you for everyone🙏**
540
588
 
541
-
542
589
  ## 🌹 Thanks
590
+
543
591
  - [franciscop/translate](https://github.com/franciscop/translate.git)
544
592
 
545
593
  > Note:Thanks to [franciscop/translate](https://github.com/franciscop/translate.git) for giving me ideas for a quick implementation of this library, and also indirectly some of his code. Much appreciated.🙏
@@ -547,4 +595,3 @@ export interface TencentEngineOption extends BaseEngineOption {
547
595
  ## 📄 License
548
596
 
549
597
  Translate is released under the MIT license. See the [`LICENSE`](./LICENSE) file.
550
-
package/README_zh-CN.md CHANGED
@@ -11,6 +11,7 @@
11
11
  Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套简单的api,让你可以轻松将一种语种翻译成另外一种语种。
12
12
 
13
13
  ## ❓ 为什么需要Translate?
14
+
14
15
  1. 市面上不少翻译工具库,基本都不太维护了
15
16
  2. 不是ts写的,使用时提示不够友好
16
17
  3. 功能单一,不支持批量翻译 or 只支持一种翻译引擎
@@ -19,6 +20,7 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
19
20
  > 说明:Translate 全部帮你搞定以上问题,未来将拓展更多内容
20
21
 
21
22
  ## ✨ 特点
23
+
22
24
  - 🌐 **多环境支持**:Node环境、浏览器环境
23
25
  - ✨ **简单易用**:提供了简洁的API,就可以轻松帮你翻译
24
26
  - 🌍 **支持多翻译引擎**:Google、Azure Translate、Amazon Translate、Deepl、Baidu、OpenAI等(未来将拓展更多)
@@ -28,6 +30,8 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
28
30
 
29
31
  > **特别提醒:虽然库已支持浏览器环境使用,但是请仅使用google engine翻译(google不需要key),使用其他翻译engine 需要配置key,在前端使用会导致key泄露,千万不要这么做**
30
32
 
33
+ > 浏览器产物已排除 Node 专用工具,例如文件系统辅助方法。浏览器环境请仅使用适合在前端暴露的翻译能力。
34
+
31
35
  ## 💻翻译引擎,集成情况
32
36
 
33
37
  | name | 支持 | 描述 |
@@ -41,6 +45,39 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
41
45
  | tencent | ✔ | 已投产,可以正常使用 |
42
46
  | yandex | | 由于我没有平台支持的银行账号,所以未调通(欢迎有条件的朋友帮忙调通,感谢) |
43
47
 
48
+ ## 🛠 开发命令
49
+
50
+ 当前项目已将 `rollup`、`eslint`、`prettier` 分别替换为 `rolldown`、`oxlint`、`oxfmt`。
51
+
52
+ ```bash
53
+ pnpm build
54
+ pnpm lint
55
+ pnpm lint:fix
56
+ pnpm format
57
+ pnpm format:check
58
+ pnpm test
59
+ ```
60
+
61
+ - `pnpm build`:使用 `rolldown` 构建 Node 与浏览器产物,并用 TypeScript 生成 `.d.ts` 声明文件。
62
+ - `pnpm lint`:执行 `oxlint` 和 `oxfmt --check`。
63
+ - `pnpm lint:fix`:执行 `oxlint --fix` 并用 `oxfmt` 自动格式化代码。
64
+ - `pnpm format`:使用 `oxfmt` 格式化仓库代码。
65
+ - `pnpm test`:运行默认稳定、无需外网的测试。
66
+
67
+ 依赖真实网络和第三方密钥的集成测试默认关闭。如需手动运行,请先设置 `RUN_INTEGRATION_TESTS=true` 再执行 `pnpm test`。
68
+
69
+ - Bash
70
+
71
+ ```bash
72
+ RUN_INTEGRATION_TESTS=true pnpm test
73
+ ```
74
+
75
+ - PowerShell
76
+
77
+ ```powershell
78
+ $env:RUN_INTEGRATION_TESTS = "true"
79
+ pnpm test
80
+ ```
44
81
 
45
82
  ## 🚀 安装
46
83
 
@@ -67,16 +104,19 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
67
104
  ### Node
68
105
 
69
106
  - ESM
107
+
70
108
  ```typescript
71
- import { translator, engines } from "@yxw007/translate"
109
+ import { translator, engines } from "@yxw007/translate";
72
110
  ```
73
111
 
74
112
  - Commonjs
113
+
75
114
  ```typescript
76
- const { translator, engines } = required("@yxw007/translate")
115
+ const { translator, engines } = required("@yxw007/translate");
77
116
  ```
78
117
 
79
118
  - 翻译例子
119
+
80
120
  ```typescript
81
121
  translator.addEngine(engines.google);
82
122
  const res1 = await translator.translate("hello", { from: "en", to: "zh" });
@@ -87,18 +127,22 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
87
127
  ```
88
128
 
89
129
  输出结果
130
+
90
131
  ```bash
91
132
  ['你好']
92
133
  ["你好", "好的"]
93
134
  ```
135
+
94
136
  - 语言检测例子
137
+
95
138
  ```typescript
96
139
  translator.addEngine(engines.google);
97
- const res1 = await translator.checkLanguage("hello", { engine:"google" });
140
+ const res1 = await translator.checkLanguage("hello", { engine: "google" });
98
141
  console.log(res1);
99
142
  ```
100
143
 
101
144
  输出结果
145
+
102
146
  ```bash
103
147
  en
104
148
  ```
@@ -108,6 +152,7 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
108
152
  使用 jsDelivr CDN
109
153
 
110
154
  - `development`
155
+
111
156
  ```html
112
157
  <script src="https://cdn.jsdelivr.net/npm/@yxw007/translate@0.0.7/dist/browser/index.umd.js"></script>
113
158
  ```
@@ -208,8 +253,8 @@ translate: <T extends Engines>(text: string | string[], opts: EngineTranslateOpt
208
253
  读取指定 Engine 的语言列表。
209
254
 
210
255
  ```typescript
211
- translator.getFromLanguages("google")
212
- translator.getToLanguages("google")
256
+ translator.getFromLanguages("google");
257
+ translator.getToLanguages("google");
213
258
  ```
214
259
 
215
260
  #### TranslateOptions
@@ -299,11 +344,10 @@ interface AzureEngineOption extends BaseEngineOption {
299
344
 
300
345
  - 相关文档:[rest-api-guide](https://learn.microsoft.com/zh-cn/azure/ai-services/translator/reference/rest-api-guide?WT.mc_id=Portal-Microsoft_Azure_ProjectOxford)
301
346
 
302
-
303
347
  #### AmazonEngineOption
304
348
 
305
349
  ```typescript
306
- interface AmazonEngineOption extends BaseEngineOption{
350
+ interface AmazonEngineOption extends BaseEngineOption {
307
351
  region: string;
308
352
  accessKeyId: string;
309
353
  secretAccessKey: string;
@@ -386,34 +430,34 @@ export type OpenAIModel = (typeof OPEN_AI_MODELS)[number];
386
430
 
387
431
  ```typescript
388
432
  export interface TencentEngineOption extends BaseEngineOption {
389
- secretId: string;
390
- secretKey: string;
391
- region?: string;
433
+ secretId: string;
434
+ secretKey: string;
435
+ region?: string;
392
436
  }
393
437
  ```
394
438
 
395
439
  > 说明:option param 请从对应平台获取。
440
+
396
441
  - 相关文档:https://console.cloud.tencent.com/cam/capi
397
442
 
398
443
  - region 配置表
399
- | 地域 | 取值 |
444
+ | 地域 | 取值 |
400
445
  | ---------------------- | ---------------- |
401
- | 亚太东南(曼谷) | ap-bangkok |
402
- | 华北地区(北京) | ap-beijing |
403
- | 西南地区(成都) | ap-chengdu |
404
- | 西南地区(重庆) | ap-chongqing |
405
- | 华南地区(广州) | ap-guangzhou |
406
- | 港澳台地区(中国香港) | ap-hongkong |
407
- | 亚太东北(首尔) | ap-seoul |
408
- | 华东地区(上海) | ap-shanghai |
409
- | 华东地区(上海金融) | ap-shanghai-fsi |
410
- | 华南地区(深圳金融) | ap-shenzhen-fsi |
411
- | 亚太东南(新加坡) | ap-singapore |
412
- | 亚太东北(东京) | ap-tokyo |
413
- | 欧洲地区(法兰克福) | eu-frankfurt |
414
- | 美国东部(弗吉尼亚) | na-ashburn |
415
- | 美国西部(硅谷) | na-siliconvalley |
416
-
446
+ | 亚太东南(曼谷) | ap-bangkok |
447
+ | 华北地区(北京) | ap-beijing |
448
+ | 西南地区(成都) | ap-chengdu |
449
+ | 西南地区(重庆) | ap-chongqing |
450
+ | 华南地区(广州) | ap-guangzhou |
451
+ | 港澳台地区(中国香港) | ap-hongkong |
452
+ | 亚太东北(首尔) | ap-seoul |
453
+ | 华东地区(上海) | ap-shanghai |
454
+ | 华东地区(上海金融) | ap-shanghai-fsi |
455
+ | 华南地区(深圳金融) | ap-shenzhen-fsi |
456
+ | 亚太东南(新加坡) | ap-singapore |
457
+ | 亚太东北(东京) | ap-tokyo |
458
+ | 欧洲地区(法兰克福) | eu-frankfurt |
459
+ | 美国东部(弗吉尼亚) | na-ashburn |
460
+ | 美国西部(硅谷) | na-siliconvalley |
417
461
 
418
462
  ## 🤝 贡献
419
463
 
@@ -426,8 +470,8 @@ export interface TencentEngineOption extends BaseEngineOption {
426
470
  ```
427
471
 
428
472
  - 添加新Engine
429
-
430
473
  - 添加新平台engine插件
474
+
431
475
  ```typescript
432
476
  export interface XXEngineOption extends BaseEngineOption {
433
477
  key: string;
@@ -459,7 +503,8 @@ export interface TencentEngineOption extends BaseEngineOption {
459
503
  };
460
504
  }
461
505
  ```
462
- - 将插件添加至engines(位置:```/src/engines/index.ts```)
506
+
507
+ - 将插件添加至engines(位置:`/src/engines/index.ts`)
463
508
 
464
509
  ```typescript
465
510
  import { xxx } from "./xxx";
@@ -470,9 +515,10 @@ export interface TencentEngineOption extends BaseEngineOption {
470
515
  baidu,
471
516
  deepl,
472
517
  openai,
473
- xxx
518
+ xxx,
474
519
  } as const;
475
520
  ```
521
+
476
522
  - 添加对应Engine支持的origin语言配置
477
523
 
478
524
  ```typescript
@@ -527,9 +573,14 @@ export interface TencentEngineOption extends BaseEngineOption {
527
573
  ...
528
574
  xxx: ValuesOf<typeof xxx>;
529
575
  };
576
+ ```
577
+
578
+ ```
579
+
530
580
  ```
531
581
 
532
582
  - 打包
583
+
533
584
  ```bash
534
585
  pnpm build
535
586
  ```
@@ -540,10 +591,11 @@ export interface TencentEngineOption extends BaseEngineOption {
540
591
  ```
541
592
 
542
593
  > **提示:目前库已可以正常使用,欢迎大家体验、如果你有任何问题和建议都可以提Issue给我反馈。
543
- 如果你感兴趣,特别欢迎你的加入,让我们一起完善好这个工具。
544
- 帮忙点个star⭐,让更多人知道这个工具,感谢大家🙏**
594
+ > 如果你感兴趣,特别欢迎你的加入,让我们一起完善好这个工具。
595
+ > 帮忙点个star⭐,让更多人知道这个工具,感谢大家🙏**
545
596
 
546
597
  ## 🌹 特别致谢
598
+
547
599
  - [franciscop/translate](https://github.com/franciscop/translate.git)
548
600
 
549
601
  > 说明:感谢[franciscop/translate](https://github.com/franciscop/translate.git)为我快速实现这个库提供了思路,同时也间接了他的部分代码。非常感谢🙏