Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to develop a Multi language Chat application which can convert any text from one language to another using Python.

I have tried couple of solutions and I found the Microsoft Bing Translate Api a perfect solution for my requirement.

I am posting this question and answer together since I thought it might help others.

What I have tried:

I have tried Google translate and Microsoft Translate, I have found Microsoft Translate Api as slightly better than the others.

hope the solution I found will be useful for similar requirements, please find it below.
Posted
Updated 7-May-19 1:47am

This is not the proper place for such an entry. If you have something useful to share then please write an Article or Tip. See Submission Guidelines[^].
 
Share this answer
 
Python
# Please install Microsoft translate using >> pip install translate

from translate import Translator

class clsTranslate():

    def translateText(self, strString, strTolang):
        self.strString = strString
        self.strTolang = strTolang
        translator = Translator(to_lang=self.strTolang)
        translation = translator.translate(self.strString)
        return (str(translation))

# Create a Class object and call the Translate function

objTrans=clsTranslate()
strTranslatedText= objTrans.translateText('How are you', 'de')

print(strTranslatedText)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900