diff --git a/requirements.txt b/requirements.txt index 833ef1c..632877a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ browser-cookie3==0.17.0 +googletrans==4.0.0rc1 requests==2.28.2 diff --git a/roadmap.md b/roadmap.md index 2d074e8..07e5442 100644 --- a/roadmap.md +++ b/roadmap.md @@ -8,7 +8,7 @@ ## Improve the post by including a photo of the menu. Requirements: - [ ] Ask Google Translate to translate menu from Danish to English. + [x] Ask Google Translate to translate menu from Danish to English. [ ] Ask Crayion to generate images of the menu in English. [ ] Include a random image from the Crayion results as an attachment in the Slack post. diff --git a/slack.py b/slack.py index 27b4757..e740a9c 100644 --- a/slack.py +++ b/slack.py @@ -12,6 +12,7 @@ import random from urllib import error, parse, request import browser_cookie3 +from googletrans import Translator import requests @@ -78,6 +79,10 @@ else: menu = menu["Menutekst"] sys.stdout.write(f"The menu of today ({today}) is: {menu}\n") + # Translate menu from Danish to English. + translation = Translator().translate(menu, src="da", dest="en").text + sys.stdout.write(f"English translation of the menu is: {translation}\n") + # Determine appropriate emojis for the menu. emojis = [] for emoji, keywords in {