Spaces:
Sleeping
Sleeping
| # 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() | |