Performance optimization: batch translation for 5-10x speed improvement

- GoogleTranslationProvider: Added batch translation with separator method
- DeepLTranslationProvider: Added translator caching and batch support
- LibreTranslationProvider: Added translator caching and batch support
- WordTranslator: Collect all texts -> batch translate -> apply pattern
- ExcelTranslator: Collect all texts -> batch translate -> apply pattern
- PowerPointTranslator: Collect all texts -> batch translate -> apply pattern
- Enhanced Ollama/OpenAI prompts with stricter translation-only rules
- Added rule: return original text if uncertain about translation
This commit is contained in:
2025-11-30 20:41:20 +01:00
parent 54d85f0b34
commit 8f9ca669cf
5 changed files with 430 additions and 423 deletions

View File

@@ -319,6 +319,9 @@ async def translate_document(
if validation_result.warnings:
logger.warning(f"[{request_id}] File validation warnings: {validation_result.warnings}")
# Reset file position after validation read
await file.seek(0)
# Check rate limit for translations
client_ip = request.client.host if request.client else "unknown"
if not await rate_limit_manager.check_translation_limit(client_ip):