From de88d9fe0fd0d8fe847a20a397479d89ee7a9e2a Mon Sep 17 00:00:00 2001 From: GMAnon Date: Sun, 25 Dec 2022 23:35:48 -0300 Subject: [PATCH] Also does it for variable thingys --- Auto Trans/Translator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Auto Trans/Translator.py b/Auto Trans/Translator.py index 4cfbe3e..b6db771 100644 --- a/Auto Trans/Translator.py +++ b/Auto Trans/Translator.py @@ -19,12 +19,12 @@ times = [] def translate(string): # Split the string by it's tags - tokens = re.findall(r'\b\w+\b|{[^}]*}|[^\w\s]|\s+', string) + tokens = re.findall(r'\b\w+\b|{[^}]*}|\[.*\]|[^\w\s]|\s+', string) # We encode this bitch up so that google trans doesn't botch the tags to_restore = [] for idx, token in enumerate(tokens): - if token[0] == "{": + if token[0] == "{" or token[0] == "[": to_restore.append(token) # Emojis aren't touched by the translator and retain their position 😎 tokens[idx] = "🔠"