kopia lustrzana https://github.com/ihabunek/toot
Fixed translation of boosted toots
rodzic
3cb548ae3a
commit
27088b1219
|
@ -586,10 +586,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:
|
||||
|
@ -604,14 +604,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
|
||||
)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue