Language Translation in Python Using Deep Translator

🌍 Language Translation in Python using Deep Translator

Want to translate text in Python? With the deep-translator library, you can easily use Google Translate to convert text into many languages. This is perfect for apps, chatbots, or any project that needs quick translations.

🚀 Why Use Deep Translator?

  • ✅ Easy to use
  • ✅ Supports multiple translation providers
  • ✅ Handles more than 50 languages
  • ✅ No need for complex API setup

🛠️ Installation

First, install the library in your Python environment:


pip install deep-translator

đŸ’ģ Python Code for Language Translation

Here’s a complete example of how to translate the word "Atul" into multiple languages using a dictionary of language codes.


from deep_translator import GoogleTranslator
# By Atul Kushwaha

# Translate "Hello" into Hindi

Sentence="Hello"
Source_language="en" # english
Translated_language="hi" # hindi

result = GoogleTranslator(source=Source_language, target=Translated_language).translate(Sentence)
print("Translation in Hindi:", result)


# Translation in Hindi: ā¤¨ā¤Žā¤¸्⤤े


Output


# Translation in Hindi: ā¤¨ā¤Žā¤¸्⤤े

📜 List of Supported Languages

Here’s a quick reference table of supported languages with their codes:

Language Code
Englishen
Hindihi
Arabicar
Spanishes
Chinese (Simplified)zh-CN
Chinese (Traditional)zh-TW
Frenchfr
Germande
Portuguesept
Russianru
Japaneseja
Koreanko
Bengalibn
Urduur
Turkishtr
Italianit
Vietnamesevi
Indonesianid
Persian (Farsi)fa
Thaith
Dutchnl
Greekel
Hebrewhe
Polishpl
Romanianro
Ukrainianuk
Swedishsv
Hungarianhu
Czechcs
Filipino (Tagalog)tl
Malayms
Tamilta
Telugute
Kannadakn
Marathimr
Gujaratigu
Punjabipa
Swahilisw
Serbiansr
Croatianhr
Slovaksk
Finnishfi
Norwegianno
Danishda

✅ Conclusion

Using Deep Translator in Python makes it super easy to translate text across multiple languages. This is especially useful for multilingual applications, AI projects, chatbots, or content localization. With just a few lines of code, you can automate translations into dozens of global languages.

Pro Tip: Always handle exceptions to skip unsupported languages gracefully.

Previous Post Next Post

Contact Form