mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
refactor: clarify parallel batch execution
Made-with: Cursor
This commit is contained in:
@@ -152,15 +152,18 @@ async function main() {
|
|||||||
const readmePath = path.join(__dirname, '../../README.md');
|
const readmePath = path.join(__dirname, '../../README.md');
|
||||||
const readmeContent = fs.readFileSync(readmePath, 'utf8');
|
const readmeContent = fs.readFileSync(readmePath, 'utf8');
|
||||||
|
|
||||||
// Translate languages in batches
|
// Translate languages in batches (parallel within batch)
|
||||||
const results = [];
|
const results = [];
|
||||||
for (let i = 0; i < targetLangs.length; i += BATCH_SIZE) {
|
for (let i = 0; i < targetLangs.length; i += BATCH_SIZE) {
|
||||||
const batch = targetLangs.slice(i, i + BATCH_SIZE);
|
const batch = targetLangs.slice(i, i + BATCH_SIZE);
|
||||||
console.log(`\nBatch ${Math.floor(i / BATCH_SIZE) + 1}/${Math.ceil(targetLangs.length / BATCH_SIZE)}: ${batch.join(', ')}`);
|
console.log(`\nBatch ${Math.floor(i / BATCH_SIZE) + 1}/${Math.ceil(targetLangs.length / BATCH_SIZE)}: ${batch.join(', ')}`);
|
||||||
|
console.log('Starting translations in parallel...\n');
|
||||||
|
|
||||||
const batchResults = await Promise.allSettled(
|
// Start all translations in parallel (don't await yet)
|
||||||
batch.map(lang => translateToLanguage(readmeContent, lang))
|
const batchPromises = batch.map(lang => translateToLanguage(readmeContent, lang));
|
||||||
);
|
|
||||||
|
// Wait for all to complete
|
||||||
|
const batchResults = await Promise.allSettled(batchPromises);
|
||||||
|
|
||||||
results.push(...batchResults);
|
results.push(...batchResults);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user