-
-
Notifications
You must be signed in to change notification settings - Fork 5
#233: implement translation feature #234
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
base: master
Are you sure you want to change the base?
#233: implement translation feature #234
Conversation
| await message.author.send("Translation is currently unavailable(no api key)") | ||
| translator = deepl.Translator(constants.DEEPL_API_KEY) | ||
| try: | ||
| translated_text = translator.translate_text(message.content, target_lang="EN-US").text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task will probably take some time. Wrap it in a async with ctx.channel.typing(): so that SAM indicates that he is "writing" on the server while waiting for the result. This way the users will know that he is doing something.
And what about embedded messsages? Most of the info messages on the server are so called Embeds and a lot of times message.content will be empty. You therefore also need to iterate over message.embeds and translate the content of them as well.
| except DeepLException: | ||
| await message.author.send("Translation is currently unavailable") | ||
| return | ||
| await message.author.send("Original:\n{}\n\nTranslated:\n{}".format(message.content, translated_text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discord messages have a char limit of 2000 for non-Nitro and 4000 for Nitro users. By showing both the original and the translated version, this will often exceed these limits.
A better way to do this would be to create an Embed instead of a normal message. In an embed you can use markdown to create hyperlinks. This way you could simply link the message url from the original and paste the translated version into a field from the embed.
A good tool for designing embeds is this for example: https://leovoel.github.io/embed-visualizer/
Co-authored-by: PKlempe <49726903+PKlempe@users.noreply.github.com>
Co-authored-by: PKlempe <49726903+PKlempe@users.noreply.github.com>
Co-authored-by: PKlempe <49726903+PKlempe@users.noreply.github.com>
No description provided.