From e6355fb9676bef00a649d05217c7a875b19034eb Mon Sep 17 00:00:00 2001 From: Krishnavamshi <85016790+krishnavamshidevandla@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:39:04 +0530 Subject: [PATCH] Create 002_English_French_Translation.md As the second project of the repository is not working, I have updated the project with another file. Where the function of the project is to translate between English and French. Instead of using requests module, I used googletrans module to translate. --- 002_English_French_Translation.md | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 002_English_French_Translation.md diff --git a/002_English_French_Translation.md b/002_English_French_Translation.md new file mode 100644 index 0000000..86d7239 --- /dev/null +++ b/002_English_French_Translation.md @@ -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() + +```