Fix language indicator showing the wrong language

This commit is contained in:
deadcade 2022-08-27 16:38:38 +02:00
parent 1713a5180d
commit 6a27b369af

View file

@ -377,7 +377,7 @@ async def reaction_callback(room: nio.MatrixRoom, event: nio.UnknownEvent, react
translated = lt.translate(original_body, from_lang, "en")
except Exception:
return await send_text(room.room_id, "Something went wrong translating the message!")
lang = lt.detect(reacted_to_event.body)[0]["language"].upper() if from_lang == "auto" else from_lang.upper()
lang = lt.detect(original_body)[0]["language"].upper() if from_lang == "auto" else from_lang.upper()
return await send_reply(room.room_id, reacted_to_event, "Translated from " + lang + " (" + flag_emoji("US" if lang == "EN" else lang) + "):\n" + translated + "\n")
async def message_callback(room: nio.MatrixRoom, event: nio.RoomMessageText) -> None: