Adds the ability to download translated documents as PDF files while
preserving the original document layout. Key changes:
- Add apply_translations() function to merge translation JSON with UnifiedDocument
- Add generate_translated_pdf() method to PDFGeneratorService
- Add POST /api/v2/translate/{task_id}/pdf endpoint
- Add downloadTranslatedPdf() method and PDF button in frontend
- Add comprehensive unit tests (52 tests: merge, PDF generation, API endpoints)
- Archive add-translated-pdf-export proposal
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
1.4 KiB
1.4 KiB
Change: Add Translated PDF Export
Why
The current translation feature produces JSON output files ({filename}_translated_{lang}.json) but does not support generating translated PDFs. Users need to download translated documents in PDF format with the original layout preserved but with translated text content. This is essential for document localization workflows where the final deliverable must be a properly formatted PDF.
What Changes
- PDF Generator: Add translation parameter support to
PDFGeneratorService - Translation Merger: Create logic to merge translation JSON with UnifiedDocument
- API Endpoint: Add
POST /api/v2/translate/{task_id}/pdfendpoint - Frontend UI: Add "Download Translated PDF" button in TaskDetailPage
- Batch Translation Enhancement: Improve batch response parsing for edge cases
Impact
- Affected specs:
translation,result-export - Affected code:
backend/app/services/pdf_generator_service.py- Add translation renderingbackend/app/services/translation_service.py- Add PDF generation integrationbackend/app/routers/translate.py- Add PDF download endpointfrontend/src/pages/TaskDetailPage.tsx- Add PDF download buttonfrontend/src/services/apiV2.ts- Add PDF download API method
Non-Goals
- Editing translated text before PDF export (future feature)
- Supporting formats other than PDF (Excel, Word)
- Font substitution for different target languages