Skip to content

Commit b330ccf

Browse files
committed
.
1 parent a68c401 commit b330ccf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/api/blueprints/security_routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def upload_file():
7070
file_type = "epub"
7171
elif original_filename.endswith('.srt'):
7272
file_type = "srt"
73+
elif original_filename.endswith('.docx'):
74+
file_type = "docx"
7375
else:
7476
file_type = "txt"
7577

src/core/docx/docx_translation_adapter.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ async def translate_content(
279279

280280
# Restore statistics
281281
stats = TranslationMetrics.from_dict(resume_state.stats) if resume_state.stats else TranslationMetrics()
282+
stats.total_chunks = len(chunks) # Ensure total_chunks is set from restored chunks
282283

283284
# Restore tag_preserver
284285
tag_preserver = self.tag_preserver
@@ -319,6 +320,10 @@ async def translate_content(
319320
metadata = context['metadata']
320321

321322
# 4. Translation with checkpoint support
323+
# For DOCX, we have a single file so global stats = local stats
324+
total_chunks = len(chunks)
325+
completed_chunks = len(translated_chunks) if translated_chunks else 0
326+
322327
translated_chunks, stats, was_interrupted = await _translate_all_chunks_with_checkpoint(
323328
chunks=chunks,
324329
source_language=source_language,
@@ -340,6 +345,9 @@ async def translate_content(
340345
global_tag_map=global_tag_map,
341346
stats=stats,
342347
prompt_options=prompt_options,
348+
# Pass global stats for DOCX (single file = global stats)
349+
global_total_chunks=total_chunks,
350+
global_completed_chunks=completed_chunks,
343351
)
344352

345353
# If interrupted, save state and return partial result

0 commit comments

Comments
 (0)