Adds a utility function to translate text to English, handles errors gracefully.

#330
by rgjuni0r - opened

This function relies on the Deep Translator library (deep-translator) to perform the translation. The source language is set to 'auto' for automatic detection, and the target language is fixed to 'en' (English).

If any issues occur during the process (e.g., connectivity or invalid input), a ValueError is raised with the specific error message for easier debugging.

Dependencies:

  • deep-translator library must be installed (pip install deep-translator).

Example usage:

translated_text = translate_to_english("Olá, como você está?")
print(translated_text)  # Output: "Hello, how are you?"
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment