Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change translate to translate any messages not in the channel lang #44

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

himmelmaus
Copy link
Contributor

This might be a little IO heavy but I liked the idea so thought I'd take a crack

Copy link
Collaborator

@neanias neanias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions

translate_url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key={}&text={}&lang={}-{}".format(api_key, text, lang, bot.config["System"]["lang"])
api_response = requests.get(translate_url).text
api_json = json.loads(api_response)
print(api_json)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you print this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an edited version of the previous function solely for translating russian, in the original it had been printed so i left it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it serves a purpose any more and could probably be taken out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alt text

def translate(bot, text):
api_key = bot.config['Yandex']['translate_key']
lang = detect(text)
translate_url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key={}&text={}&lang={}-{}".format(api_key, text, lang, bot.config["System"]["lang"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this line pass the linter? Looks rather long to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah whole thing got passed

@himmelmaus
Copy link
Contributor Author

in conversation with @hreeder we discussed using google translate instead of Yandex, does anybody have any opinions either way?

@neanias
Copy link
Collaborator

neanias commented Oct 18, 2018

I say just go for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants