From 0d87a789e0530793cc14c35795c00b7470364d0f Mon Sep 17 00:00:00 2001 From: blank X Date: Wed, 21 Oct 2020 21:28:27 +0700 Subject: [PATCH] Fix translate --- sukuinote/plugins/translate.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sukuinote/plugins/translate.py b/sukuinote/plugins/translate.py index 30d2348..c81dc2f 100644 --- a/sukuinote/plugins/translate.py +++ b/sukuinote/plugins/translate.py @@ -23,14 +23,16 @@ async def translate(client, message): lang = ' '.join(message.command[1:]).lower() for i in PROBLEM_CODES: if lang.startswith(i): - src_lang = i - lang = lang[len(i):] + lang = lang[len(i) + 1:] if lang: - dest_lang = lang[1:] or 'en' + src_lang = i + dest_lang = lang + else: + dest_lang = i break else: lang = lang.split('-', 1) - if len(lang) == 1: + if len(lang) == 1 or not lang[-1]: dest_lang = lang.pop(0) or dest_lang else: src_lang, dest_lang = lang