Subscribe Us

Header Ads

Translate Any Language with Just 3 Lines of Python! | python translator app | Hindi, Gujarati & more

Are you tired of copying and pasting text into Google Translate? With just 3 lines of Python code, you can translate any language using the translate library. In this tutorial, we’ll show you how to translate text from English to Hindi.

First, make sure you have the translate library installed by running pip install translate in your command line. Then, import the translate library into your Python




import translate

  
Copy


Next, create a Translator object and specify the source and target languages. In this example, we’re translating from English (en-in) to Hindi (hi).


t = translate.Translator(from_lang="en-in",to_lang="hi")

  
Copy


Finally, use the translate method to translate your text. Here’s an example that translates the phrase “jai shree ram” from English to Hindi:


print(t.translate("jai shree ram"))
#Output:जय श्री राम 

  
Copy


And that’s it! With just 3 lines of code, you can easily translate any language using Python. Try it out with other languages like Gujarati, Marathi, and more!

Kindly refer to This Page for a table of supported languages. For a full detailed explanatory video in Hindi, please see the video below:

Post a Comment

0 Comments