Python Translator – How to make ? English to Bengali or other Translator

Here I will show how to make a python tanslator. My translate language will be Bengali/Bangla and it will save to a file. Here I have made a short youtube video to show how to do it.

 

Codes:

from translate import Translator
translator= Translator(to_lang="bn")

try:
    with open('for_translation.txt', mode='r') as text_for_translation_text:
        text_for_translation=text_for_translation_text.read()
        translation = translator.translate(text_for_translation)
        print(translation)
        with open('save_the_translation.txt', mode='w', encoding="utf-8") as text_after_translation:
            text_after_translation.write(translation)

except FileNotFoundError as e:
    print('Please check the file path dear user :)')

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *