gpt-po 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -5
- package/README_zh-CN.md +7 -3
- package/lib/package.json +1 -1
- package/lib/src/utils.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# PO File Translation Tool for ChatGPT
|
2
2
|
|
3
|
+
[![NPM version](https://img.shields.io/npm/v/gpt-po.svg)](https://npmjs.org/package/gpt-po)
|
4
|
+
[![Downloads](https://img.shields.io/npm/dm/gpt-po.svg)](https://npmjs.org/package/gpt-po)
|
5
|
+
|
3
6
|
Translation tool for gettext (po) files that supports custom system prompts and user dictionaries. It also supports translating specified po files to a designated target language and updating po files based on pot files.
|
4
7
|
|
5
8
|
Read in other languages: English | [简体中文](./README_zh-CN.md)
|
@@ -7,7 +10,7 @@ Read in other languages: English | [简体中文](./README_zh-CN.md)
|
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
```
|
10
|
-
npm install
|
13
|
+
npm install gpt-po
|
11
14
|
```
|
12
15
|
|
13
16
|
Set `OPENAI_API_KEY` before using this tool.
|
@@ -16,10 +19,10 @@ Set `OPENAI_API_KEY` before using this tool.
|
|
16
19
|
|
17
20
|
## Usage Scenarios
|
18
21
|
|
19
|
-
- `gpt-po sync --po <file> --pot <file>`
|
20
|
-
- `gpt-po --po <file>`
|
21
|
-
- `gpt-po userdict`
|
22
|
-
- `gpt-po systemprompt`
|
22
|
+
- `gpt-po sync --po <file> --pot <file>` Update the po file based on the pot file, while preserving the original translations.
|
23
|
+
- `gpt-po --po <file>` Translate specified po files to a designated target language. By default, the target language is Simplified Chinese.
|
24
|
+
- `gpt-po userdict` Modify or view user dictionaries
|
25
|
+
- `gpt-po systemprompt` Modify or view system prompts, if you are not sure how to use it, you can leave it alone
|
23
26
|
|
24
27
|
```
|
25
28
|
Usage: gpt-po [command] [options]
|
@@ -49,6 +52,7 @@ Options:
|
|
49
52
|
--model <model> openai model (choices: "gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314", "gpt-3.5-turbo", "gpt-3.5-turbo-0301",
|
50
53
|
default: "gpt-3.5-turbo")
|
51
54
|
--po <file> po file path
|
55
|
+
-src, --source <lang> source language (default: "english")
|
52
56
|
-l, --lang <lang> target language (default: "simplified chinese")
|
53
57
|
-o, --output <file> output file path, overwirte po file by default
|
54
58
|
-h, --help display help for command
|
package/README_zh-CN.md
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
# PO文件CHATGPT翻译工具
|
2
2
|
|
3
|
+
[![NPM version](https://img.shields.io/npm/v/gpt-po.svg)](https://npmjs.org/package/gpt-po)
|
4
|
+
[![Downloads](https://img.shields.io/npm/dm/gpt-po.svg)](https://npmjs.org/package/gpt-po)
|
5
|
+
|
3
6
|
gettext(po)文件翻译工具,支持自定义系统提示词和用户字典,支持翻译指定的po文件到指定的目标语言,支持根据pot文件更新po文件。
|
4
7
|
|
5
|
-
使用其他语言阅读:[English](./
|
8
|
+
使用其他语言阅读:[English](./README.md) | 简体中文
|
6
9
|
|
7
10
|
## 安装
|
8
11
|
|
9
12
|
```
|
10
|
-
npm install
|
13
|
+
npm install gpt-po
|
11
14
|
```
|
12
15
|
|
13
16
|
使用此工具前先设置 `OPENAI_API_KEY`,Windows中使用 `set OPENAI_API_KEY=<key>`, Linux中 `export OPENAI_API_KEY=<key>`
|
@@ -16,7 +19,7 @@ npm install openai
|
|
16
19
|
|
17
20
|
## 常见用法
|
18
21
|
|
19
|
-
- `gpt-po sync --po <file> --pot <file>` 根据pot文件更新po
|
22
|
+
- `gpt-po sync --po <file> --pot <file>` 根据pot文件更新po文件,保留原有翻译
|
20
23
|
- `gpt-po --po <file>` 翻译指定的po文件到指定的目标语言,默认目标语言是简体中文
|
21
24
|
- `gpt-po userdict` 修改或查看用户字典
|
22
25
|
- `gpt-po systemprompt` 修改或查看系统提示词,如果你不确定如何使用,可以不用修改
|
@@ -49,6 +52,7 @@ Options:
|
|
49
52
|
--model <model> openai model (choices: "gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314", "gpt-3.5-turbo", "gpt-3.5-turbo-0301",
|
50
53
|
default: "gpt-3.5-turbo")
|
51
54
|
--po <file> po file path
|
55
|
+
-src, --source <lang> source language (default: "english")
|
52
56
|
-l, --lang <lang> target language (default: "simplified chinese")
|
53
57
|
-o, --output <file> output file path, overwirte po file by default
|
54
58
|
-h, --help display help for command
|
package/lib/package.json
CHANGED
package/lib/src/utils.js
CHANGED
@@ -36,7 +36,7 @@ function parsePo(poFile, defaultCharset) {
|
|
36
36
|
}
|
37
37
|
exports.parsePo = parsePo;
|
38
38
|
function compilePo(data, poFile) {
|
39
|
-
const buffer = gettext_parser_1.po.compile(data);
|
39
|
+
const buffer = gettext_parser_1.po.compile(data, { foldLength: 120 });
|
40
40
|
return new Promise((resolve, reject) => {
|
41
41
|
fs.writeFile(poFile, buffer, (err) => {
|
42
42
|
if (err)
|