Skip to content

Commit 4e107f1

Browse files
committed
fixed: mptl to tlm
1 parent 7549392 commit 4e107f1

File tree

9 files changed

+49
-51
lines changed

9 files changed

+49
-51
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
## 安装
1616

1717
```
18-
npm install -g mptl
18+
npm install -g tlm
1919
```
2020

2121
## 使用
2222

2323
```
24-
Usage: mptl command [options]
24+
Usage: tlm command [options]
2525
2626
Options:
2727
-v, --version 输出当前版本
@@ -36,36 +36,36 @@ Commands:
3636
set-langs [options] 设置源语言和目标语言
3737
-s, --source <source> 设置源语言
3838
-t, --target <target> 设置目标语言
39-
p <query...> 使用 'mptl p <query...>' 指令翻译文本
39+
p <query...> 使用 'tlm p <query...>' 指令翻译文本
4040
help [command] 显示命令的帮助
4141
```
4242

4343
## 示例
4444

4545
```
46-
$ mptl set-trl baidu -a 123456 -s abcdefghijklmnopqrstuvwxyz
46+
$ tlm set-trl baidu -a 123456 -s abcdefghijklmnopqrstuvwxyz
4747
4848
设置百度翻译平台的应用ID和密钥
4949
50-
$ mptl ls
50+
$ tlm ls
5151
5252
查看翻译平台列表和当前选中的平台
5353
54-
$ mptl use youdao
54+
$ tlm use youdao
5555
5656
使用有道翻译平台进行翻译
5757
58-
$ mptl ls langs
58+
$ tlm ls langs
5959
6060
查看当前可以选择的源语言和目标语言代码
6161
62-
$ mptl set-langs -s en -t zh
62+
$ tlm set-langs -s en -t zh
6363
6464
设置翻译源语言为英语,目标语言为中文
6565
66-
$ mptl p hello world
66+
$ tlm p hello world
6767
68-
mptl p 跟上需要翻译的文本内容
68+
tlm p 跟上需要翻译的文本内容
6969
```
7070
## 支持平台
7171

@@ -79,7 +79,7 @@ $ mptl p hello world
7979
## 注意事项
8080

8181
- 翻译插件本身并没有翻译文字的能力,而是通过调用翻译平台提供的API进行翻译,目前支持的平台都有免费的翻译额度,对于大部分人来说是完全足够的。
82-
- 除了谷歌翻译,所有翻译平台都需要去申请应用ID和密钥,具体申请教程请看:[翻译平台API申请教程](https://flowus.cn/chiko_mptl/share/c721cbc9-6537-41e5-99b9-fd6299ec5b01?code=B8NQGQ)
82+
- 除了谷歌翻译,所有翻译平台都需要去申请应用ID和密钥,具体申请教程请看:[翻译平台API申请教程](https://flowus.cn/chiko_tlm/share/c721cbc9-6537-41e5-99b9-fd6299ec5b01?code=B8NQGQ)
8383
- 由于本插件是终端运行,也并没有提供服务器的打算,所以谷歌翻译需要通过代理才能使用,如果开启代理还不能使用,请开启代理的Tun模式。
8484

8585

README_EN.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
## Install
1616

1717
```
18-
npm install -g mptl
18+
npm install -g tlm
1919
```
2020

2121
## Usage
2222

2323
```
24-
Usage: mptl command [options]
24+
Usage: tlm command [options]
2525
2626
Options:
2727
-v, --version Output the current version
@@ -36,35 +36,35 @@ Commands:
3636
set-langs [options] Set source and target languages
3737
-s, --source <source> Set source language
3838
-t, --target <target> Set target language
39-
p <query...> Translate the text using the 'mptl p <query...>' directive
39+
p <query...> Translate the text using the 'tlm p <query...>' directive
4040
help [command] display help for command
4141
```
4242

4343
## Example
4444
```
45-
$ mptl set-trl baidu -a 123456 -s abcdefghijklmnopqrstuvwxyz
45+
$ tlm set-trl baidu -a 123456 -s abcdefghijklmnopqrstuvwxyz
4646
4747
Set the application ID and key of Baidu Translation Platform
4848
49-
$ mptl ls
49+
$ tlm ls
5050
5151
View the list of translation platforms and the currently selected platform
5252
53-
$ mptl ls langs
53+
$ tlm ls langs
5454
5555
View the currently available source and target language codes
5656
57-
$ mptl use youdao
57+
$ tlm use youdao
5858
5959
Use Youdao translation platform for translation
6060
61-
$ mptl set-langs -s en -t zh
61+
$ tlm set-langs -s en -t zh
6262
6363
Set the translation source language to English and the target language to Chinese
6464
65-
$ mptl p hello world
65+
$ tlm p hello world
6666
67-
mptl p Keep up with the text that needs to be translated
67+
tlm p Keep up with the text that needs to be translated
6868
```
6969
## Supported Platforms
7070

@@ -78,7 +78,7 @@ $ mptl p hello world
7878
## Precautions
7979

8080
- The translation plug-in itself does not have the ability to translate text, but instead translates by calling the API provided by the translation platform. Currently supported platforms have free translation quotas, which is completely sufficient for most people.
81-
- Except for Google Translate, all translation platforms need to apply for application ID and key, Please see the specific tutorial: [Translation platform API application tutorial](https://flowus.cn/chiko_mptl/share/c721cbc9-6537-41e5-99b9-fd6299ec5b01?code=B8NQGQ).
81+
- Except for Google Translate, all translation platforms need to apply for application ID and key, Please see the specific tutorial: [Translation platform API application tutorial](https://flowus.cn/chiko_tlm/share/c721cbc9-6537-41e5-99b9-fd6299ec5b01?code=B8NQGQ).
8282
- Since this plug-in runs in the terminal and there is no plan to provide a server, Google Translate needs to be used through a proxy. If it still does not work after turning on the proxy, please turn on the Tun mode of the proxy.
8383

8484
## Connect

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "mptl",
2+
"name": "tlm",
33
"version": "0.0.1",
44
"type": "module",
55
"description": "Terminal packages that support multiple translation platforms",
66
"main": "./dist/cli.js",
77
"bin": {
8-
"mptl": "./dist/cli.js"
8+
"tlm": "./dist/cli.js"
99
},
1010
"scripts": {
1111
"start": "tsc-watch --onSuccess \"tsc-alias\"",
@@ -25,10 +25,8 @@
2525
"README_EN.md"
2626
],
2727
"keywords": [
28-
"mptl",
28+
"tlm",
2929
"translate",
30-
"translation",
31-
"translator",
3230
"language",
3331
"multi-platform",
3432
"multi-platform-translate"

src/bin/translator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Adapters from ".";
2-
import { MPTLRC } from "@/constants";
2+
import { TLMRC } from "@/constants";
33
import { readFile } from "@util/helpers";
44

5-
const { pl: name } = <Tl.Config>await readFile(MPTLRC);
5+
const { pl: name } = <Tl.Config>await readFile(TLMRC);
66

77
type keys = keyof typeof Adapters;
88

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const program = new Command();
1717

1818
program.version(version, '-v, --version', 'Output the current version');
1919

20-
program.name("mptl").usage("command [options]");
20+
program.name("tlm").usage("command [options]");
2121

2222
program
2323
.command("ls [langs]")
@@ -46,7 +46,7 @@ program
4646
program
4747
.command("p")
4848
.argument("<query...>")
49-
.description("Translate the text using the 'mptl p <query...>' directive")
49+
.description("Translate the text using the 'tlm p <query...>' directive")
5050
.action(onTranslate)
5151

5252
program.parse(process.argv);

src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const __fileName = fileURLToPath(import.meta.url);
55
const __dirname = path.dirname(__fileName);
66
const CONFIG_PATH = path.join(__dirname, '../config.json');
77
const PACKAGE_PATH = path.join(__dirname, '../package.json');
8-
const MPTLRC = path.join(<string>process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.mptlrc.json');
8+
const TLMRC = path.join(<string>process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.tlmrc.json');
99

1010
const LANGUAGE_MAP = [
1111
{ zh: "自动检测", en: "auto", code: "auto" },
@@ -34,7 +34,7 @@ const DEFAULTLANGUAGE = {
3434
};
3535

3636
export {
37-
MPTLRC,
37+
TLMRC,
3838
CONFIG_PATH,
3939
PACKAGE_PATH,
4040
LANGUAGE_ZH,

src/updated_config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { isExistConfig, readFile, writeFile } from "@util/helpers";
2-
import { MPTLRC, CONFIG_PATH } from "@/constants";
2+
import { TLMRC, CONFIG_PATH } from "@/constants";
33

44
(async () => {
55
const config = <Tl.Config>await readFile(CONFIG_PATH);
6-
const isExist = await isExistConfig(MPTLRC);
6+
const isExist = await isExistConfig(TLMRC);
77
if (!isExist) {
8-
await writeFile(MPTLRC, config);
8+
await writeFile(TLMRC, config);
99
} else {
10-
const localConfig = await readFile(MPTLRC);
10+
const localConfig = await readFile(TLMRC);
1111
Object.assign(config, localConfig);
12-
await writeFile(MPTLRC, config);
12+
await writeFile(TLMRC, config);
1313
}
1414
})();

src/util/controller.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as languages from "@bin/langs";
33
import {
44
LANGUAGE_MAP,
55
DEFAULTLANGUAGE,
6-
MPTLRC,
6+
TLMRC,
77
LANGUAGE_ZH
88
} from "@/constants";
99
import {
@@ -28,14 +28,14 @@ async function isTranslationPlatformNotFound(name: string, print = true) {
2828
const { platform } = await getPlatformInfo();
2929
const keys = platform.map(item => item[0]);
3030
if (!keys.includes(name)) {
31-
print && errorLog(`不支持 \`${name}\` 翻译平台,请使用 \`mptl ls\` 命令查看可支持平台`);
31+
print && errorLog(`不支持 \`${name}\` 翻译平台,请使用 \`tlm ls\` 命令查看可支持平台`);
3232
return true;
3333
}
3434
return false;
3535
}
3636

3737
async function languageListHandle() {
38-
const config = <Tl.Config>await readFile(MPTLRC);
38+
const config = <Tl.Config>await readFile(TLMRC);
3939
const { source, pl } = config;
4040
const { sourceMap, targetMap } = (<{ [key: string]: Tl.LangsConfig }>languages)[pl];
4141
const condition: { [key: string]: boolean } = { "include": false, "exclude": true };
@@ -69,7 +69,7 @@ async function showPlatformList() {
6969

7070
async function showLanguageList(len = 14) {
7171
const langsList = await languageListHandle();
72-
const { source, target } = <Tl.Config>await readFile(MPTLRC);
72+
const { source, target } = <Tl.Config>await readFile(TLMRC);
7373
const map: { [key: string]: string } = { source, target };
7474

7575
console.log(`\n- ${chalk.blue('蓝色')}高亮文本为当前选中语种\n- ${chalk.red('红色')}高亮文本为当前不支持语种\n- 不同翻译平台的不同语种支持略有差异\n`);
@@ -96,17 +96,17 @@ async function showLanguageList(len = 14) {
9696

9797
async function changePlatform(name: string) {
9898
if (await isTranslationPlatformNotFound(name)) return;
99-
const config = <Tl.Config>await readFile(MPTLRC);
99+
const config = <Tl.Config>await readFile(TLMRC);
100100
const { source, target } = config;
101101
config.pl = name;
102-
await writeFile(MPTLRC, config);
102+
await writeFile(TLMRC, config);
103103
const plName = await getPlatformName(name);
104104
successLog(`正在使用${plName}翻译平台`);
105105
await changeLanguageCode({ source, target }, { printSuc: false });
106106
}
107107

108108
async function changeLanguageCode(langs: Tl.DefaultLangs, { printSuc = true, printErr = true }) {
109-
const config = <Tl.Config>await readFile(MPTLRC);
109+
const config = <Tl.Config>await readFile(TLMRC);
110110
const { source, target, pl } = config;
111111
const map = Object.assign({ source, target }, langs);
112112
const { codeMap, sourceMap, targetMap } = (<{ [key: string]: Tl.LangsConfig }>languages)[pl];
@@ -131,16 +131,16 @@ async function changeLanguageCode(langs: Tl.DefaultLangs, { printSuc = true, pri
131131
}
132132
config[key] = map[key];
133133
}
134-
await writeFile(MPTLRC, config);
134+
await writeFile(TLMRC, config);
135135
}
136136

137137
async function setTranslation(name: string, { appid, secretKey }: { appid: string, secretKey: string }) {
138138
if (await isTranslationPlatformNotFound(name)) return;
139-
const config = <Tl.Config>await readFile(MPTLRC);
139+
const config = <Tl.Config>await readFile(TLMRC);
140140
const platform = config.platform[name];
141141
platform.appid = appid ?? platform.appid;
142142
platform.key = secretKey ?? platform.key;
143-
await writeFile(MPTLRC, config);
143+
await writeFile(TLMRC, config);
144144
const plName = await getPlatformName(name);
145145
successLog(`${plName}翻译平台成功设置应用ID和秘钥`);
146146
}

src/util/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "fs";
22
import chalk from "chalk";
33
import stringWidth from "string-width";
4-
import { LANGUAGE_MAP, MPTLRC } from "@/constants";
4+
import { LANGUAGE_MAP, TLMRC } from "@/constants";
55
import * as languages from "@bin/langs";
66

77
async function readFile(file: string) {
@@ -37,13 +37,13 @@ async function isExistConfig(path: string): Promise<boolean> {
3737
}
3838

3939
async function getPlatformInfo() {
40-
const config = <Tl.Config>await readFile(MPTLRC);
40+
const config = <Tl.Config>await readFile(TLMRC);
4141
const platform = Object.entries(config.platform);
4242
return { pl: config.pl, platform }
4343
}
4444

4545
async function getPlatformConfig(name: string) {
46-
const config = <Tl.Config>await readFile(MPTLRC);
46+
const config = <Tl.Config>await readFile(TLMRC);
4747
const platform = config.platform[name];
4848
const source = config.source, target = config.target, pl = config.pl;
4949
return { ...platform, source, target, pl }

0 commit comments

Comments
 (0)