@yxw007/translate 0.0.1-alpha.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.
package/LICENSE ADDED
@@ -0,0 +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.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Translate
2
+
3
+ English | [简体中文](./README_zh-CN.md)
4
+
5
+ ![GitHub top language](https://img.shields.io/github/languages/top/yxw007/translate)
6
+ ![GitHub License](https://img.shields.io/github/license/yxw007/translate)
7
+
8
+ ## ❓ Why do I need translate?
9
+ 1. a lot of translation tool libraries on the market, basically not very well-maintained
10
+ 2. not written by ts, not friendly enough when using the prompts
11
+ 3. single function, does not support batch translation Or only support a translation engine
12
+ 4. ...
13
+
14
+ > Note: Translate helps you to solve all the above problems, and will expand more in the future!
15
+
16
+ ## ✨ Features
17
+ - 🌐 **Multi-environment support**: Node environment, browser environment
18
+ - ✨ **Easy to use**: provides a concise API, you can easily help you to translate
19
+ - 🌍 **Multi-translation engine support**: Google, Azure Translate, etc. (will expand more in the future)
20
+ - 🛠️ **typescript**: friendlier code hints and quality assurance
21
+ - 📦 **Batch translation**: one api request, translate more content, reduce http requests to improve translation efficiency
22
+ - 🔓 **completely open source**.
23
+
24
+ ## 🚀 Install
25
+
26
+ - npm
27
+
28
+ ```bash
29
+ npm install @yxw007/translate
30
+ ```
31
+
32
+ - yarn
33
+
34
+ ```bash
35
+ yarn add @yxw007/translate
36
+ ```
37
+
38
+ - pnpm
39
+
40
+ ```bash
41
+ pnpm i @yxw007/translate
42
+ ```
43
+
44
+ ## 📖 Usage
45
+
46
+ - ESM
47
+
48
+ ```typescript
49
+ import { translator, engines } from "@yxw007/translate"
50
+
51
+ translator.use(engines.google());
52
+ const res1 = await translator.translate("hello", { from: "en", to: "zh" });
53
+ console.log(res1);
54
+
55
+ const res2 = await translator.translate(["hello", "good"], { from: "en", to: "zh", engine: "google" });
56
+ console.log(res2);
57
+ ```
58
+
59
+ output
60
+ ```bash
61
+ ['你好']
62
+ ["你好", "好的"]
63
+ ```
64
+
65
+ - Commonjs
66
+
67
+ ```typescript
68
+ const { translator, engines } = required("@yxw007/translate")
69
+
70
+ translator.use(engines.google());
71
+ const res1 = await translator.translate("hello", { from: "en", to: "zh" });
72
+ console.log(res1);
73
+
74
+ const res2 = await translator.translate(["hello", "good"], { from: "en", to: "zh", engine: "google" });
75
+ console.log(res2);
76
+
77
+ ```
78
+
79
+ output
80
+ ```bash
81
+ ['你好']
82
+ ["你好", "好的"]
83
+ ```
84
+
85
+ ## 📄 License
86
+
87
+ Translate is released under the MIT license. See the [`LICENSE`](./LICENSE) file.
88
+
@@ -0,0 +1,90 @@
1
+ # Translate
2
+
3
+ 简体中文 | [English](./README.md)
4
+
5
+ ![GitHub top language](https://img.shields.io/github/languages/top/yxw007/translate)
6
+ ![GitHub License](https://img.shields.io/github/license/yxw007/translate)
7
+
8
+ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套简单的api,让你可以轻松将一种语种翻译成另外一种语种。
9
+
10
+ ## ❓ 为什么需要Translate?
11
+ 1. 市面上不少翻译工具库,基本都不太维护了
12
+ 2. 不是ts写的,使用时提示不够友好
13
+ 3. 功能单一,不支持批量翻译 or 只支持一种翻译引擎
14
+ 4. ...
15
+
16
+ > 说明:Translate 全部帮你搞定以上问题,未来将拓展更多内容
17
+
18
+ ## ✨ 特点
19
+ - 🌐 **多环境支持**:Node环境、浏览器环境
20
+ - ✨ **简单易用**:提供了简洁的API,就可以轻松帮你翻译
21
+ - 🌍 **支持多翻译引擎**:Google、Azure Translate等(未来将拓展更多)
22
+ - 🛠️ **typescript**: 更友好的代码提示和质量保障
23
+ - 📦 **批量翻译**:一次api请求,翻译更多内容,减少http请求提高翻译效率
24
+ - 🔓 **完全开源**
25
+
26
+
27
+ ## 🚀 安装
28
+
29
+ - npm
30
+
31
+ ```bash
32
+ npm install @yxw007/translate
33
+ ```
34
+
35
+ - yarn
36
+
37
+ ```bash
38
+ yarn add @yxw007/translate
39
+ ```
40
+
41
+ - pnpm
42
+
43
+ ```bash
44
+ pnpm i @yxw007/translate
45
+ ```
46
+
47
+ ## 📖 使用
48
+
49
+ - ESM
50
+
51
+ ```typescript
52
+ import { translator, engines } from "@yxw007/translate"
53
+
54
+ translator.use(engines.google());
55
+ const res1 = await translator.translate("hello", { from: "en", to: "zh" });
56
+ console.log(res1);
57
+
58
+ const res2 = await translator.translate(["hello", "good"], { from: "en", to: "zh", engine: "google" });
59
+ console.log(res2);
60
+ ```
61
+
62
+ 输出结果
63
+ ```bash
64
+ ['你好']
65
+ ["你好", "好的"]
66
+ ```
67
+
68
+ - Commonjs
69
+
70
+ ```typescript
71
+ const { translator, engines } = required("@yxw007/translate")
72
+
73
+ translator.use(engines.google());
74
+ const res1 = await translator.translate("hello", { from: "en", to: "zh" });
75
+ console.log(res1);
76
+
77
+ const res2 = await translator.translate(["hello", "good"], { from: "en", to: "zh", engine: "google" });
78
+ console.log(res2);
79
+
80
+ ```
81
+
82
+ 输出结果
83
+ ```bash
84
+ ['你好']
85
+ ["你好", "好的"]
86
+ ```
87
+
88
+ ## 📄 许可证
89
+
90
+ Translate 是在 MIT 许可证下发布的。详情请见 [`LICENSE`](./LICENSE) 文件。