In this project we gonna translate English text file to French text file. Before start the program we need to install the required packages. I’m using juypter so i gonna directly install by using !pip install googletrans and !conda install googletrans, After install import the packages by using import keyword.
languages names along with their shorthand notation given in the output, so this will help to choose the language short form. In here we going to translate from English to French language, for French shorthand is fr.
The Google Translate API is used for translating words or sentences from one language into another and we create the class Translator. Now we want to read the file.
After read the file, pass the contents variable containing the input text to the translate() function and we mention the destination is French as fr.
Finally we write this output in text file using write method. when you use API that's make our work easier and make our code short.