Skip to content
Merged
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
12 changes: 12 additions & 0 deletions language_translator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## USER GUIDE

### Pre-requisites
```
1) Googletrans python library
$ pip install googletrans
```
### How to run the script?
```
$ python we-can-use-google-trans.py
```
Once done the script will prompt for input.
15 changes: 15 additions & 0 deletions language_translator/we-can-use-google-trans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import googletrans
from googletrans import Translator

# Get the list of languages from the google translate API
langList = googletrans.LANGUAGES
# Get the input from the user
inputSentence = input("Please enter a sentence to translate :\n")
translator = Translator()
# Detect the Language
sourceLang = translator.detect(inputSentence).lang
sourceLang = langList[sourceLang]
# Get the translation
translateString = translator.translate(inputSentence).text

print("The language detected was: " + sourceLang + "\n" + "The translation is: " + translateString)