syncmaster6 / test_translation.py
aseelflihan's picture
Initial commit without node_modules
6123728
# test_translation.py - Quick translation test
from translator import get_translator
import json
def test_translation():
print("πŸ” Testing AI Translation System...")
# Get translator instance
translator = get_translator()
if translator.init_error:
print(f"❌ Translation Error: {translator.init_error}")
return
print("βœ… Translator initialized successfully")
# Test translation
test_text = "Hello, this is a test for the translation system"
print(f"\nπŸ”€ Original text: {test_text}")
translated_text, error = translator.translate_text(test_text, target_language='ar')
if translated_text:
print(f"βœ… Arabic translation: {translated_text}")
print(f"πŸ“Š Translation success: True")
print(f"πŸ”„ Texts are different: {translated_text != test_text}")
else:
print(f"❌ Translation failed: {error}")
# Test language detection
detected_lang, detect_error = translator.detect_language(test_text)
if detected_lang:
print(f"🌍 Detected language: {detected_lang}")
else:
print(f"❌ Language detection failed: {detect_error}")
if __name__ == "__main__":
test_translation()