Skip to content

Commit 0fdd55f

Browse files
committed
Fix retries
1 parent ea8a72f commit 0fdd55f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/i18n/tasks/translators/openai_translator.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ def translate_batch(batch, from, to, retry_count = 0)
9595

9696
if result.size != batch.size
9797
if retry_count < RETRIES
98-
translate_batch(batch, from, to, retry_count)
98+
translate_batch(batch, from, to, retry_count + 1)
9999
elsif retry_count == RETRIES
100-
# Try each string individually
101-
batch.each do |string|
102-
translate_batch([string], from, to, RETRIES + 1)
100+
# Try each string individually once
101+
result = []
102+
batch.map do |string|
103+
result << translate_batch([string], from, to, RETRIES + 1)
103104
end
104105
else
105106
error = I18n.t('i18n_tasks.openai_translate.errors.invalid_size', expected: batch.size, actual: result.size)

0 commit comments

Comments
 (0)