Skip to content

Commit 9448d8a

Browse files
committed
feat(cli): add --engine option
1 parent 461be51 commit 9448d8a

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

bin/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ pipeline(
3737
desc: locale.CMD_DES_TO,
3838
default: 'auto',
3939
})
40+
.options('engine', {
41+
alias: 'e',
42+
type: 'string',
43+
choices: ['google', 'microsoft'],
44+
desc: locale.CMD_DES_ENGINE,
45+
default: () => process.env.NODE_TRANSLATE_CLI_ENGINE ?? 'google',
46+
defaultDescription: '"google"',
47+
})
4048
.options('timeout', {
4149
type: 'number',
4250
desc: locale.CMD_DES_TIMEOUT,

src/locale/en-US.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default {
44
'The source language (language to be translated from) specified as language name or ISO 639-1 code',
55
CMD_DES_TO:
66
'The target language (language to be translated to) specified as language name or ISO 639-1 code',
7+
CMD_DES_ENGINE: 'Select translation engine',
78
CMD_DES_TIMEOUT:
89
'Timeout duration for the translation request in milliseconds',
910
CMD_DES_STDIN_TIMEOUT:

src/locale/zh-CN.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ export default {
22
CMD_DSE_USAGE: '$0 <文本> [选项]',
33
CMD_DES_FROM: '源语言(要翻译的语言) 指定为语言名称或ISO 639-1代码',
44
CMD_DES_TO: '目标语言(要翻译的语言) 指定为语言名称或ISO 639-1代码',
5-
CMD_DES_TIMEOUT: '翻译请求的超时持续时间(以毫秒为单位)',
6-
CMD_DES_STDIN_TIMEOUT: '使用此参数来避免 stdin 超时 (以毫秒为单位)',
5+
CMD_DES_ENGINE: '翻译引擎',
6+
CMD_DES_TIMEOUT: '翻译请求的超时持续时间 (以毫秒为单位)',
7+
CMD_DES_STDIN_TIMEOUT: '使用此参数来避免 stdin 超时 (以毫秒为单位)',
78
CMD_DES_RETRY: '失败时试图重试翻译请求次数',
89
CMD_DES_SHOW_PHONETICS: '查看翻译文本的单词发音',
910
CMD_DES_SHOW_SOURCE: '查看源文本信息',

src/shared/argument-vector.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export interface ArgumentVector {
22
_: string[];
33
from: string;
44
to: string;
5+
engine: 'google' | 'microsoft';
56
timeout: number;
67
stdinTimeout: number;
78
retry: number;

0 commit comments

Comments
 (0)