Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ProcessMaker/Http/Controllers/Api/OpenAIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ public function languageTranslation(Request $request)
$processTranslationToken->save();

$translateProcess = new BatchesJobHandler($process, $screensTranslations, $request->input('language'), $code, Auth::id(), $option);
$translateProcess->handle();
$haveStringsToTranslate = $translateProcess->handle();
if (!$haveStringsToTranslate) {
return response()->json([
'error' => __('No strings found to translate'),
]);
}
} else {
return response()->json([
'error' => 'Already running a translation for this language in background',
Expand Down
9 changes: 8 additions & 1 deletion ProcessMaker/ProcessTranslations/BatchesJobHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function handle()
[$screensWithChunks, $chunksCount] = $this->prepareData($this->screens, $languageTranslationHandler);

// Execute requests for each regular chunk

$batch = Bus::batch([])
->then(function (Batch $batch) {
\Log::info('All jobs in batch completed');
Expand All @@ -79,6 +78,12 @@ public function handle()
// Update with real batch token ...
ProcessTranslationToken::where('token', $this->code)->update(['token' => $batch->id]);

if (!count($screensWithChunks)) {
$this->notifyProgress($batch);

return false;
}

foreach ($screensWithChunks as $screenId => $screenWithChunks) {
foreach ($screenWithChunks as $chunk) {
$batch->add(
Expand All @@ -93,6 +98,8 @@ public function handle()
);
}
}

return true;
}

private function notifyProgress($batch)
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@
"Validate that an attribute has a valid URL format.": "Validate that an attribute has a valid URL format.",
"Add Rule": "Add Rule",
"No validation rule(s)": "No validation rule(s)",
"No strings found to translate": "No strings found to translate",
"New Select List": "New Select List",
"New Array of Objects": "New Array of Objects",
"Existing Array": "Existing Array",
Expand Down