Skip to content

Commit deaa5e1

Browse files
committed
feat: add --concurrency to translate
1 parent 0a0eaf2 commit deaa5e1

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/translate/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ program
3737
'--max <number>',
3838
'Maximum number of files to process in one batch (per language) (default: unlimited)',
3939
)
40+
.option(
41+
'--concurrency <number>',
42+
'Number of concurrent translation tasks (default: 10)',
43+
)
4044
.action(
4145
async (options: {
4246
config?: string;
@@ -46,6 +50,7 @@ program
4650
listOnly?: boolean;
4751
targetLanguage?: string;
4852
max?: number;
53+
concurrency?: number;
4954
}) => {
5055
if (options.verbose) {
5156
logger.setVerbose(true);
@@ -60,6 +65,7 @@ program
6065
...(options.pattern ? { pattern: options.pattern } : {}),
6166
...(options.docsPath ? { docsPath: options.docsPath } : {}),
6267
...(options.max ? { max: options.max } : {}),
68+
...(options.concurrency ? { concurrency: options.concurrency } : {}),
6369
listOnly: options.listOnly,
6470
targetLanguage: options.targetLanguage,
6571
});

packages/translate/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function main({
2222
listOnly,
2323
max = Number.POSITIVE_INFINITY,
2424
targetLanguage,
25+
concurrency = 10,
2526
}: MainConfig): Promise<void> {
2627
// Filter languages based on targetLanguage if specified
2728
const filteredLangs = targetLanguage
@@ -190,7 +191,6 @@ export async function main({
190191
// Process tasks if not in list-only mode
191192
if (!listOnly) {
192193
let completedRefDocs = 0;
193-
const concurrency = 10;
194194

195195
await executeInBatches(
196196
tasks,

packages/translate/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface MainConfig {
2727
max?: number;
2828
listOnly?: boolean;
2929
targetLanguage?: string;
30+
concurrency?: number;
3031
}
3132

3233
export interface TranslationResult {

0 commit comments

Comments
 (0)