Skip to content

Commit f9ec8af

Browse files
author
bram
committed
Fixed issues
1 parent 9dd4956 commit f9ec8af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

python_gpt_po/services/translation_service.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ def perform_translation_without_validation(
206206
target_language: str,
207207
detail_language: Optional[str] = None) -> str:
208208
"""Performs translation without validation for single words or short phrases."""
209-
# Extract leading/trailing whitespace from original
210-
leading_ws = text[:len(text) - len(text.lstrip())]
211-
trailing_ws = text[len(text.rstrip()):]
209+
# Strip text before sending to AI (whitespace will be restored in validate_translation)
212210
text_stripped = text.strip()
213211

214212
# Use the detailed language name if provided, otherwise use the short code
@@ -297,15 +295,17 @@ def _process_bulk_response(
297295
response_text: str,
298296
original_texts: List[str],
299297
target_language: str,
300-
stripped_texts: Optional[List[str]] = None) -> List[str]:
298+
_stripped_texts: Optional[List[str]] = None) -> List[str]:
301299
"""Process a bulk translation response.
302300
303301
Args:
304302
response_text: The raw response from the AI provider
305303
original_texts: The original texts WITH whitespace
306304
target_language: Target language code
307-
stripped_texts: The stripped texts that were sent to AI (for validation)
305+
_stripped_texts: The stripped texts sent to AI (unused, for future use)
308306
"""
307+
# Note: _stripped_texts parameter kept for future validation features
308+
# Current validation happens per-entry using original_texts
309309
try:
310310
# Clean the response text for formatting issues
311311
clean_response = self._clean_json_response(response_text)

python_gpt_po/tests/test_whitespace_preservation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Tests for whitespace preservation in translations.
33
"""
44
import unittest
5-
from unittest.mock import MagicMock, patch
5+
from unittest.mock import patch
66

77
import polib
88

0 commit comments

Comments
 (0)