Skip to content
Open
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
39 changes: 39 additions & 0 deletions 002_English_French_Translation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# English French Translation

## Requirements

1. Run the code in console using command line.
2. It'll ask you to input English or French words or sentence. Then it'll print the related translation text.
3. If you input 'q' it'll stop to ask then quit the program.

## What will we practice in this project?

- while loop
- input text
- if conditions
- dictionary
- googletrans module

## A reference code

```python
from googletrans import Translator

def translator():
translator = Translator()
while True:
given = input("Please input English or French word for translation : ")
if given == 'q':
break
language = translator.detect(given).lang
if language == 'en':
ans = translator.translate(given, dest='fr')
print("Translation of your english word is : " + ans.text)
elif language == 'fr':
ans = translator.translate(given, dest='en')
print("Translation of your french word is : " + ans.text)
else:
print("Give a proper input")
translator()

```