Files
pictorialink-ComfyUI-Text-T…/utils/translation.py
T
2025-06-04 15:50:20 +08:00

25 lines
841 B
Python

def translators(text : str , translator: str = "bing", source_language = "auto", target_language = "en", timeout: float = 10.0):
if not text:
return ""
try:
import translators
result = translators.translate_text(query_text = text, translator = translator,from_language = source_language, to_language= target_language, timeout= timeout)
return result
except Exception as e:
raise Exception(f"Error: Translation failed , Message : {e}")
def get_translator():
try:
import translators
translators_list = translators.translators_pool
result = '\n'.join(translators_list)
print(f"Text Translation translator: \n{result}")
return result
except Exception as e:
raise Exception(f"Error: Translation failed , Message : {e}")