Fixed translation of boosted toots

pull/328/head
Dan Schwarz 2023-03-04 16:04:13 -05:00
rodzic 3cb548ae3a
commit 27088b1219
2 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -586,10 +586,10 @@ class TUI(urwid.Frame):
def async_translate(self, timeline, status): def async_translate(self, timeline, status):
def _translate(): def _translate():
logger.info("Translating {}".format(status)) 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: try:
response = api.translate(self.app, self.user, status.id) response = api.translate(self.app, self.user, status.original.id)
if response["content"]: if response["content"]:
self.footer.set_message("Status translated") self.footer.set_message("Status translated")
else: else:
@ -604,14 +604,14 @@ class TUI(urwid.Frame):
def _done(response): def _done(response):
if response is not None: if response is not None:
status.translation = response["content"] status.original.translation = response["content"]
status.translated_from = response["detected_source_language"] status.original.translated_from = response["detected_source_language"]
status.show_translation = True status.original.show_translation = True
timeline.update_status(status) timeline.update_status(status)
# If already translated, toggle showing translation # If already translated, toggle showing translation
if status.translation: if status.original.translation:
status.show_translation = not status.show_translation status.original.show_translation = not status.original.show_translation
timeline.update_status(status) timeline.update_status(status)
else: else:
self.run_in_thread(_translate, done_callback=_done) self.run_in_thread(_translate, done_callback=_done)

Wyświetl plik

@ -340,7 +340,7 @@ class StatusDetails(urwid.Pile):
if status.data["spoiler_text"] and not status.show_sensitive: if status.data["spoiler_text"] and not status.show_sensitive:
yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view."))) yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view.")))
else: 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): for line in format_content(content):
yield ("pack", urwid.Text(highlight_hashtags(line, self.followed_tags))) 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")) yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "gray"))
translated_from = ( translated_from = (
language_name(status.translated_from) language_name(status.original.translated_from)
if status.show_translation and status.translated_from if status.original.show_translation and status.original.translated_from
else None else None
) )