mirror of
https://github.com/ihabunek/toot.git
synced 2024-10-27 05:10:20 -04:00
Merge pull request #328 from danschwarz/translate_fix
Fix for issue #318 translation of boosted toots doesn't work
This commit is contained in:
commit
e10bb0ebae
@ -597,10 +597,10 @@ class TUI(urwid.Frame):
|
||||
def async_translate(self, timeline, status):
|
||||
def _translate():
|
||||
logger.info("Translating {}".format(status))
|
||||
self.footer.set_message("Translating status {}".format(status.id))
|
||||
self.footer.set_message("Translating status {}".format(status.original.id))
|
||||
|
||||
try:
|
||||
response = api.translate(self.app, self.user, status.id)
|
||||
response = api.translate(self.app, self.user, status.original.id)
|
||||
if response["content"]:
|
||||
self.footer.set_message("Status translated")
|
||||
else:
|
||||
@ -615,14 +615,14 @@ class TUI(urwid.Frame):
|
||||
|
||||
def _done(response):
|
||||
if response is not None:
|
||||
status.translation = response["content"]
|
||||
status.translated_from = response["detected_source_language"]
|
||||
status.show_translation = True
|
||||
status.original.translation = response["content"]
|
||||
status.original.translated_from = response["detected_source_language"]
|
||||
status.original.show_translation = True
|
||||
timeline.update_status(status)
|
||||
|
||||
# If already translated, toggle showing translation
|
||||
if status.translation:
|
||||
status.show_translation = not status.show_translation
|
||||
if status.original.translation:
|
||||
status.original.show_translation = not status.original.show_translation
|
||||
timeline.update_status(status)
|
||||
else:
|
||||
self.run_in_thread(_translate, done_callback=_done)
|
||||
|
@ -340,7 +340,7 @@ class StatusDetails(urwid.Pile):
|
||||
if status.data["spoiler_text"] and not status.show_sensitive:
|
||||
yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view.")))
|
||||
else:
|
||||
content = status.translation if status.show_translation else status.data["content"]
|
||||
content = status.original.translation if status.original.show_translation else status.data["content"]
|
||||
for line in format_content(content):
|
||||
yield ("pack", urwid.Text(highlight_hashtags(line, self.followed_tags)))
|
||||
|
||||
@ -369,8 +369,8 @@ class StatusDetails(urwid.Pile):
|
||||
yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "gray"))
|
||||
|
||||
translated_from = (
|
||||
language_name(status.translated_from)
|
||||
if status.show_translation and status.translated_from
|
||||
language_name(status.original.translated_from)
|
||||
if status.original.show_translation and status.original.translated_from
|
||||
else None
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user