@yxw007/translate 0.0.1-alpha.0 → 0.0.1-alpha.1
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/README.md +171 -0
- package/README_zh-CN.md +183 -0
- package/dist/index.d.ts +6 -0
- package/dist/package.json +96 -96
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@ English | [简体中文](./README_zh-CN.md)
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
7
10
|
|
|
8
11
|
## ❓ Why do I need translate?
|
|
9
12
|
1. a lot of translation tool libraries on the market, basically not very well-maintained
|
|
@@ -82,6 +85,174 @@ English | [简体中文](./README_zh-CN.md)
|
|
|
82
85
|
["你好", "好的"]
|
|
83
86
|
```
|
|
84
87
|
|
|
88
|
+
## 📚 API
|
|
89
|
+
|
|
90
|
+
### Translator
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
class Translator {
|
|
94
|
+
private engines: Map<string, Engine>;
|
|
95
|
+
constructor() {
|
|
96
|
+
this.engines = new Map<string, Engine>();
|
|
97
|
+
}
|
|
98
|
+
use(engine: Engine) {
|
|
99
|
+
...
|
|
100
|
+
}
|
|
101
|
+
translate(text: string | string[], options: TranslateOptions) {
|
|
102
|
+
...
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### `use`
|
|
108
|
+
|
|
109
|
+
Add a translation engine to transitorion engine to translator
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
type Engine = {
|
|
113
|
+
name: string;
|
|
114
|
+
translate: (text: string | string[], opts: EngineTranslateOptions) => Promise<string[]>;
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### `translate`
|
|
119
|
+
|
|
120
|
+
You can pass a text or pass a text array, which will return a translated ```Promise<string[]>```
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
translate(text: string | string[], options: TranslateOptions)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### TranslateOptions
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
export interface TranslateOptions {
|
|
130
|
+
from: Language;
|
|
131
|
+
to: Language;
|
|
132
|
+
engine?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Cache time in milliseconds
|
|
135
|
+
*/
|
|
136
|
+
cache_time?: number;
|
|
137
|
+
domain?: string;
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Each translation of Engine's Option
|
|
142
|
+
|
|
143
|
+
#### BaseEngineOption
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
interface BaseEngineOption {}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### AzureEngineOption
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
interface AzureEngineOption extends BaseEngineOption {
|
|
153
|
+
key: string;
|
|
154
|
+
region: string;
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
> Note: Option Param, please get it from the corresponding platform
|
|
159
|
+
|
|
160
|
+
- 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)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
#### AmazonEngineOption
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
interface AmazonEngineOption extends BaseEngineOption{
|
|
167
|
+
region: string;
|
|
168
|
+
accessKeyId: string;
|
|
169
|
+
secretAccessKey: string;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
> Note: Option Param, please get it from the corresponding platform
|
|
174
|
+
|
|
175
|
+
- Related documentationtive document:https://docs.aws.amazon.com/translate/latest/dg/what-is.html
|
|
176
|
+
- Related library:https://www.npmjs.com/package/@aws-sdk/client-translate
|
|
177
|
+
|
|
178
|
+
#### BaiduEngineOption
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
export interface BaiduEngineOption extends BaseEngineOption {
|
|
182
|
+
appId: string;
|
|
183
|
+
secretKey: string;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
> Note: Option Param, please get it from the corresponding platform
|
|
188
|
+
|
|
189
|
+
- Related documentation:https://fanyi-api.baidu.com/product/121
|
|
190
|
+
|
|
191
|
+
## 🤝 Contribute
|
|
192
|
+
|
|
193
|
+
> Special attention: Please create a new branch based on the master, develop on the new branch, and create PR to Master after development.
|
|
194
|
+
|
|
195
|
+
- Installation dependence
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
pnpm install
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- Add new Engine
|
|
202
|
+
|
|
203
|
+
- Add a new platform ENGINE plugin
|
|
204
|
+
```typescript
|
|
205
|
+
export interface XXEngineOption extends BaseEngineOption {
|
|
206
|
+
key: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function xx(options: XXEngineOption): Engine {
|
|
210
|
+
const { key } = options;
|
|
211
|
+
const base = "https://translate.yandex.net/api/v1.5/tr.json/translate";
|
|
212
|
+
return {
|
|
213
|
+
name: "yandex",
|
|
214
|
+
async translate(text: string | string[], opts: EngineTranslateOptions): Promise<string[]> {
|
|
215
|
+
const { from, to } = opts;
|
|
216
|
+
if (!Array.isArray(text)) {
|
|
217
|
+
text = [text];
|
|
218
|
+
}
|
|
219
|
+
//TODO: Call the platform translation APIplatform translation API
|
|
220
|
+
const translations: string[] = [];
|
|
221
|
+
//TODO: Analyze the corresponding results of the platform API, and resolve the results to the translations back
|
|
222
|
+
for (const translation of body.text) {
|
|
223
|
+
if (translation) {
|
|
224
|
+
translations.push(translation);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return translations;
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
- Add the plugin to Engines(Location:```/src/engines/index.ts```)
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import { xx } from "./xx";
|
|
236
|
+
export const engines = {
|
|
237
|
+
google,
|
|
238
|
+
azure,
|
|
239
|
+
amazon,
|
|
240
|
+
baidu,
|
|
241
|
+
xx
|
|
242
|
+
} as const;
|
|
243
|
+
```
|
|
244
|
+
- Build
|
|
245
|
+
```bash
|
|
246
|
+
pnpm build
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
- Test
|
|
250
|
+
```bash
|
|
251
|
+
pnpm test
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
> **Tip: 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🙏**
|
|
255
|
+
|
|
85
256
|
## 📄 License
|
|
86
257
|
|
|
87
258
|
Translate is released under the MIT license. See the [`LICENSE`](./LICENSE) file.
|
package/README_zh-CN.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
7
10
|
|
|
8
11
|
Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套简单的api,让你可以轻松将一种语种翻译成另外一种语种。
|
|
9
12
|
|
|
@@ -23,6 +26,16 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
|
|
|
23
26
|
- 📦 **批量翻译**:一次api请求,翻译更多内容,减少http请求提高翻译效率
|
|
24
27
|
- 🔓 **完全开源**
|
|
25
28
|
|
|
29
|
+
## 💻翻译引擎,集成情况
|
|
30
|
+
|
|
31
|
+
| name | 支持 | 描述 |
|
|
32
|
+
| ---------------- | ---- | -------------------------------------------------------------------------- |
|
|
33
|
+
| google | √ | 已投产,可以正常使用 |
|
|
34
|
+
| azure translate | √ | 已投产,可以正常使用 |
|
|
35
|
+
| amazon translate | √ | 已投产,可以正常使用 |
|
|
36
|
+
| baidu | √ | 已投产,可以正常使用 |
|
|
37
|
+
| yandex | | 由于我没有平台支持的银行账号,所以未调通(欢迎有条件的朋友帮忙调通,感谢) |
|
|
38
|
+
|
|
26
39
|
|
|
27
40
|
## 🚀 安装
|
|
28
41
|
|
|
@@ -85,6 +98,176 @@ Translate 是一个支持多翻译引擎的翻译工具库,它提供了一套
|
|
|
85
98
|
["你好", "好的"]
|
|
86
99
|
```
|
|
87
100
|
|
|
101
|
+
## 📚 API
|
|
102
|
+
|
|
103
|
+
### Translator
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
class Translator {
|
|
107
|
+
private engines: Map<string, Engine>;
|
|
108
|
+
constructor() {
|
|
109
|
+
this.engines = new Map<string, Engine>();
|
|
110
|
+
}
|
|
111
|
+
use(engine: Engine) {
|
|
112
|
+
...
|
|
113
|
+
}
|
|
114
|
+
translate(text: string | string[], options: TranslateOptions) {
|
|
115
|
+
...
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### `use`
|
|
121
|
+
|
|
122
|
+
给translator添加翻译引擎
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
type Engine = {
|
|
126
|
+
name: string;
|
|
127
|
+
translate: (text: string | string[], opts: EngineTranslateOptions) => Promise<string[]>;
|
|
128
|
+
};
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### `translate`
|
|
132
|
+
|
|
133
|
+
可以传一个文本or传一个文本数组,将返回一个翻译后的Promise<string[]>
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
translate(text: string | string[], options: TranslateOptions)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### TranslateOptions
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
export interface TranslateOptions {
|
|
143
|
+
from: Language;
|
|
144
|
+
to: Language;
|
|
145
|
+
engine?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Cache time in milliseconds
|
|
148
|
+
*/
|
|
149
|
+
cache_time?: number;
|
|
150
|
+
domain?: string;
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 各翻译Engine的Option
|
|
155
|
+
|
|
156
|
+
#### BaseEngineOption
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
interface BaseEngineOption {}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### AzureEngineOption
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
interface AzureEngineOption extends BaseEngineOption {
|
|
166
|
+
key: string;
|
|
167
|
+
region: string;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
> 说明:option param 请从对应平台获取
|
|
172
|
+
|
|
173
|
+
- 相关文档:[rest-api-guide](https://learn.microsoft.com/zh-cn/azure/ai-services/translator/reference/rest-api-guide?WT.mc_id=Portal-Microsoft_Azure_ProjectOxford)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
#### AmazonEngineOption
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
interface AmazonEngineOption extends BaseEngineOption{
|
|
180
|
+
region: string;
|
|
181
|
+
accessKeyId: string;
|
|
182
|
+
secretAccessKey: string;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
> 说明:option param 请从对应平台获取
|
|
187
|
+
|
|
188
|
+
- 相关文档:https://docs.aws.amazon.com/translate/latest/dg/what-is.html
|
|
189
|
+
- 相关库:https://www.npmjs.com/package/@aws-sdk/client-translate
|
|
190
|
+
|
|
191
|
+
#### BaiduEngineOption
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
export interface BaiduEngineOption extends BaseEngineOption {
|
|
195
|
+
appId: string;
|
|
196
|
+
secretKey: string;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
> 说明:option param 请从对应平台获取
|
|
201
|
+
|
|
202
|
+
- 相关文档:https://fanyi-api.baidu.com/product/121
|
|
203
|
+
|
|
204
|
+
## 🤝 贡献
|
|
205
|
+
|
|
206
|
+
> 特别注意:请基于master创建一个新分支,在新分支上开发,开发完后创建PR至master
|
|
207
|
+
|
|
208
|
+
- 安装依赖
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pnpm install
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- 添加新Engine
|
|
215
|
+
|
|
216
|
+
- 添加新平台engine插件
|
|
217
|
+
```typescript
|
|
218
|
+
export interface XXEngineOption extends BaseEngineOption {
|
|
219
|
+
key: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function xx(options: XXEngineOption): Engine {
|
|
223
|
+
const { key } = options;
|
|
224
|
+
const base = "https://translate.yandex.net/api/v1.5/tr.json/translate";
|
|
225
|
+
return {
|
|
226
|
+
name: "yandex",
|
|
227
|
+
async translate(text: string | string[], opts: EngineTranslateOptions): Promise<string[]> {
|
|
228
|
+
const { from, to } = opts;
|
|
229
|
+
if (!Array.isArray(text)) {
|
|
230
|
+
text = [text];
|
|
231
|
+
}
|
|
232
|
+
//TODO: 调用平台翻译api
|
|
233
|
+
const translations: string[] = [];
|
|
234
|
+
//TODO: 解析平台API相应结果,将结果解析至translations返回
|
|
235
|
+
for (const translation of body.text) {
|
|
236
|
+
if (translation) {
|
|
237
|
+
translations.push(translation);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return translations;
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
- 将插件添加至engines(位置:```/src/engines/index.ts```)
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { xx } from "./xx";
|
|
249
|
+
export const engines = {
|
|
250
|
+
google,
|
|
251
|
+
azure,
|
|
252
|
+
amazon,
|
|
253
|
+
baidu,
|
|
254
|
+
xx
|
|
255
|
+
} as const;
|
|
256
|
+
```
|
|
257
|
+
- 打包
|
|
258
|
+
```bash
|
|
259
|
+
pnpm build
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
- 测试
|
|
263
|
+
```bash
|
|
264
|
+
pnpm test
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
> **提示:目前库已可以正常使用,欢迎大家体验、如果你有任何问题和建议都可以提Issue给我反馈。
|
|
268
|
+
如果你感兴趣,特别欢迎你的加入,让我们一起完善好这个工具。
|
|
269
|
+
帮忙点个star⭐,让更多人知道这个工具,感谢大家🙏**
|
|
270
|
+
|
|
88
271
|
## 📄 许可证
|
|
89
272
|
|
|
90
273
|
Translate 是在 MIT 许可证下发布的。详情请见 [`LICENSE`](./LICENSE) 文件。
|
package/dist/index.d.ts
CHANGED
|
@@ -415,7 +415,13 @@ interface TranslateOptions {
|
|
|
415
415
|
from: Language;
|
|
416
416
|
to: Language;
|
|
417
417
|
engine?: string;
|
|
418
|
+
/**
|
|
419
|
+
* Cache time in milliseconds
|
|
420
|
+
*/
|
|
418
421
|
cache_time?: number;
|
|
422
|
+
/**
|
|
423
|
+
* Domain to use for translation
|
|
424
|
+
*/
|
|
419
425
|
domain?: string;
|
|
420
426
|
}
|
|
421
427
|
interface BaseEngineOption {
|
package/dist/package.json
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@yxw007/translate",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
4
|
-
"description": "A simple library that supports multiple translation engines",
|
|
5
|
-
"author": "Potter<aa4790139@gmail.com>",
|
|
6
|
-
"homepage": "https://
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/yxw007/translate.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/yxw007/translate/issues"
|
|
13
|
-
},
|
|
14
|
-
"publishConfig": {
|
|
15
|
-
"access": "public"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"lint": "eslint . && prettier -c src",
|
|
19
|
-
"lint:fix": "eslint . --fix && prettier -w src",
|
|
20
|
-
"build": "pnpm clean && tsx script/build.ts",
|
|
21
|
-
"clean": "rm -rf dist",
|
|
22
|
-
"test": "vitest --run",
|
|
23
|
-
"test:coverage": "vitest --coverage --run",
|
|
24
|
-
"release": "pnpm changelogen --release -i --prerelease",
|
|
25
|
-
"prepare": "husky"
|
|
26
|
-
},
|
|
27
|
-
"type": "module",
|
|
28
|
-
"main": "./dist/index.cjs",
|
|
29
|
-
"module": "./dist/index.js",
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
|
-
"exports": {
|
|
32
|
-
"require": "./dist/index.cjs",
|
|
33
|
-
"import": "./dist/index.js"
|
|
34
|
-
},
|
|
35
|
-
"files": [
|
|
36
|
-
"dist",
|
|
37
|
-
"README_zh-CN.md",
|
|
38
|
-
"README.md",
|
|
39
|
-
"package.json"
|
|
40
|
-
],
|
|
41
|
-
"keywords": [
|
|
42
|
-
"translate",
|
|
43
|
-
"translation",
|
|
44
|
-
"google",
|
|
45
|
-
"i18n",
|
|
46
|
-
"l10n",
|
|
47
|
-
"localization",
|
|
48
|
-
"internationalization"
|
|
49
|
-
],
|
|
50
|
-
"husky": {
|
|
51
|
-
"hooks": {
|
|
52
|
-
"pre-commit": "lint-staged"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"lint-staged": {
|
|
56
|
-
"**/*.{ts}": [
|
|
57
|
-
"pnpm lint:fix"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
"license": "MIT",
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@commitlint/config-conventional": "^19.2.2",
|
|
63
|
-
"@eslint/js": "^8.57.0",
|
|
64
|
-
"@rollup/plugin-alias": "^5.1.0",
|
|
65
|
-
"@rollup/plugin-commonjs": "^26.0.1",
|
|
66
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
67
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
68
|
-
"@rollup/plugin-typescript": "^11.1.6",
|
|
69
|
-
"@types/crypto-js": "^4.2.2",
|
|
70
|
-
"@types/eslint__js": "^8.42.3",
|
|
71
|
-
"@types/node": "^22.5.0",
|
|
72
|
-
"@vitest/coverage-v8": "^2.0.5",
|
|
73
|
-
"changelogen": "^0.5.5",
|
|
74
|
-
"commitlint": "^19.4.0",
|
|
75
|
-
"dotenv": "^16.4.5",
|
|
76
|
-
"eslint": "^8.57.0",
|
|
77
|
-
"globals": "^15.9.0",
|
|
78
|
-
"husky": "^9.1.5",
|
|
79
|
-
"lint-staged": "^15.2.9",
|
|
80
|
-
"prettier": "^3.3.3",
|
|
81
|
-
"rollup": "^4.21.1",
|
|
82
|
-
"rollup-plugin-dts": "^6.1.1",
|
|
83
|
-
"tslib": "^2.7.0",
|
|
84
|
-
"typescript": "^5.5.4",
|
|
85
|
-
"typescript-eslint": "^8.3.0",
|
|
86
|
-
"vitest": "^2.0.5"
|
|
87
|
-
},
|
|
88
|
-
"volta": {
|
|
89
|
-
"node": "22.3.0"
|
|
90
|
-
},
|
|
91
|
-
"dependencies": {
|
|
92
|
-
"@aws-sdk/client-translate": "^3.637.0",
|
|
93
|
-
"@smithy/smithy-client": "^3.2.0",
|
|
94
|
-
"crypto-js": "^4.2.0"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@yxw007/translate",
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
|
+
"description": "A simple library that supports multiple translation engines",
|
|
5
|
+
"author": "Potter<aa4790139@gmail.com>",
|
|
6
|
+
"homepage": "https://github.com/yxw007/translate",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/yxw007/translate.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/yxw007/translate/issues"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"lint": "eslint . && prettier -c src",
|
|
19
|
+
"lint:fix": "eslint . --fix && prettier -w src",
|
|
20
|
+
"build": "pnpm clean && tsx script/build.ts",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"test": "vitest --run",
|
|
23
|
+
"test:coverage": "vitest --coverage --run",
|
|
24
|
+
"release": "pnpm changelogen --release -i --prerelease",
|
|
25
|
+
"prepare": "husky"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.cjs",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
"require": "./dist/index.cjs",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README_zh-CN.md",
|
|
38
|
+
"README.md",
|
|
39
|
+
"package.json"
|
|
40
|
+
],
|
|
41
|
+
"keywords": [
|
|
42
|
+
"translate",
|
|
43
|
+
"translation",
|
|
44
|
+
"google",
|
|
45
|
+
"i18n",
|
|
46
|
+
"l10n",
|
|
47
|
+
"localization",
|
|
48
|
+
"internationalization"
|
|
49
|
+
],
|
|
50
|
+
"husky": {
|
|
51
|
+
"hooks": {
|
|
52
|
+
"pre-commit": "lint-staged"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"lint-staged": {
|
|
56
|
+
"**/*.{ts}": [
|
|
57
|
+
"pnpm lint:fix"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
63
|
+
"@eslint/js": "^8.57.0",
|
|
64
|
+
"@rollup/plugin-alias": "^5.1.0",
|
|
65
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
66
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
67
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
68
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
69
|
+
"@types/crypto-js": "^4.2.2",
|
|
70
|
+
"@types/eslint__js": "^8.42.3",
|
|
71
|
+
"@types/node": "^22.5.0",
|
|
72
|
+
"@vitest/coverage-v8": "^2.0.5",
|
|
73
|
+
"changelogen": "^0.5.5",
|
|
74
|
+
"commitlint": "^19.4.0",
|
|
75
|
+
"dotenv": "^16.4.5",
|
|
76
|
+
"eslint": "^8.57.0",
|
|
77
|
+
"globals": "^15.9.0",
|
|
78
|
+
"husky": "^9.1.5",
|
|
79
|
+
"lint-staged": "^15.2.9",
|
|
80
|
+
"prettier": "^3.3.3",
|
|
81
|
+
"rollup": "^4.21.1",
|
|
82
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
83
|
+
"tslib": "^2.7.0",
|
|
84
|
+
"typescript": "^5.5.4",
|
|
85
|
+
"typescript-eslint": "^8.3.0",
|
|
86
|
+
"vitest": "^2.0.5"
|
|
87
|
+
},
|
|
88
|
+
"volta": {
|
|
89
|
+
"node": "22.3.0"
|
|
90
|
+
},
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"@aws-sdk/client-translate": "^3.637.0",
|
|
93
|
+
"@smithy/smithy-client": "^3.2.0",
|
|
94
|
+
"crypto-js": "^4.2.0"
|
|
95
|
+
}
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yxw007/translate",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
4
|
"description": "A simple library that supports multiple translation engines",
|
|
5
5
|
"author": "Potter<aa4790139@gmail.com>",
|
|
6
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://github.com/yxw007/translate",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/yxw007/translate.git"
|