Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions text_translator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Using TextTranslator script
## Steps to translate :
1. Run the script `TextTranslator.py` using python.

2. After execution of the script you will be prompted to enter the Text you want to translate.

3. You will get the correct translation of the given text in English.

## NOTE : The input text could be in any language, it will be automatically detected and translated into English.
## If you want to change the output Language, you may add a dest field to translation in `TextTranslator.py` and provide the language code for the required language :
```
translation = translator.translate("INPUT_TEXT", dest="LANGUAGE_CODE")
```
9 changes: 9 additions & 0 deletions text_translator/TextTranslator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from googletrans import Translator, constants
from pprint import pprint

# init the Google API translator
translator = Translator()

# translate text in any language to english text (by default)
translation = translator.translate(input("Enter text to translate into English"))
print(f"{translation.origin} ({translation.src}) --> {translation.text} ({translation.dest})")
1 change: 1 addition & 0 deletions text_translator/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
googletrans(3.1.0a0)