-
Notifications
You must be signed in to change notification settings - Fork 115
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
Adds translate status feature (when connected to a Mastodon 4.x server with translation enabled) #252
Conversation
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.
Mailing list is fine, as are pulls on Github. The patch you sent to the mailing list does not apply, so check it out.
Thanks, this is a good patch, I have some comments before we merge.
toot/tui/timeline.py
Outdated
self._emit("translate", status) | ||
return | ||
|
||
if key in ("r", "R"): |
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.
You changed the key binding for thread here.
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.
Ouch. Not sure how that happened. Fixed.
toot/tui/app.py
Outdated
@@ -106,6 +106,7 @@ def __init__(self, app, user): | |||
self.timeline = None | |||
self.overlay = None | |||
self.exception = None | |||
self.can_translate = Option.UNKNOWN |
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.
I don't think using Option here is very beneficial and it complicates things. I would just set it to False
here, and set it to True
later when we determine if translate is available.
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.
Done
toot/tui/app.py
Outdated
""" | ||
def _load_instance(): | ||
return api.get_instance(self.app.instance) | ||
|
||
def _done(instance): | ||
if "max_toot_chars" in instance: | ||
self.max_toot_chars = instance["max_toot_chars"] | ||
if "translation" in instance: | ||
# instance is advertising translation service | ||
self.can_translate = Option.YES |
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.
Looking at mastodon/mastodon@8046cf3#diff-fdc9457d4797dfa4b6e351a974127f11b1efc7eaeadb84718976f98af3618026
Just having "translation" in instance info is not enough, we need to check if instance["translation"]["enabled"]
is True.
self.can_translate = Option.YES | |
self.can_translate = instance["translation"]["enabled"] |
(this is presuming we change this from an Option to bool)
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.
Fixed
I've pushed fixes for all of the above issues, hopefully all is good now. Enhancements for future consideration:
|
Thanks! I merged this manually and also enabled toggling translation by pressing n repeatedly. |
We don't need a library, when we can use language codes from wikipedia: 0ab0db0 |
Published in 0.32.0. Test and let me know how well it works. |
I've submitted a patch to the mailing list, but hopefully this is cleaner/easier to review.
Implementation as per mastodon/mastodon#19218
and mastodon/mastodon#19328
Screenshots of feature in action.