
- Python - Text Processing
- Python - Text Processing Introduction
- Python - Text Processing Environment
- Python - String Immutability
- Python - Sorting Lines
- Python - Reformatting Paragraphs
- Python - Counting Token in Paragraphs
- Python - Binary ASCII Conversion
- Python - Strings as Files
- Python - Backward File Reading
- Python - Filter Duplicate Words
- Python - Extract Emails from Text
- Python - Extract URL from Text
- Python - Pretty Print
- Python - Text Processing State Machine
- Python - Capitalize and Translate
- Python - Tokenization
- Python - Remove Stopwords
- Python - Synonyms and Antonyms
- Python - Text Translation
- Python - Word Replacement
- Python - Spelling Check
- Python - WordNet Interface
- Python - Corpora Access
- Python - Tagging Words
- Python - Chunks and Chinks
- Python - Chunk Classification
- Python - Text Classification
- Python - Bigrams
- Python - Process PDF
- Python - Process Word Document
- Python - Reading RSS feed
- Python - Sentiment Analysis
- Python - Search and Match
- Python - Text Munging
- Python - Text wrapping
- Python - Frequency Distribution
- Python - Text Summarization
- Python - Stemming Algorithms
- Python - Constrained Search
Python - Text Translation
Text translation from one language to another is increasingly becoming common for various websites as they cater to an international audience. The python package which helps us do this is called translate.
This package can be installed by the following way. It provides translation for major languages.
pip install translate
Below is an example of translating a simple sentence from English to German. The default from language being English.
from translate import Translator translator= Translator(to_lang="German") translation = translator.translate("Good Morning!") print translation
When we run the above program, we get the following output −
Guten Morgen!
Between Any Two Languages
If we have the need specify the from-language and the to-language, then we can specify it as in the below program.
from translate import Translator translator= Translator(from_lang="german",to_lang="spanish") translation = translator.translate("Guten Morgen") print translation
When we run the above program, we get the following output −
Buenos das
Advertisements