Also does it for variable thingys
This commit is contained in:
@ -19,12 +19,12 @@ times = []
|
|||||||
|
|
||||||
def translate(string):
|
def translate(string):
|
||||||
# Split the string by it's tags
|
# 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
|
# We encode this bitch up so that google trans doesn't botch the tags
|
||||||
to_restore = []
|
to_restore = []
|
||||||
for idx, token in enumerate(tokens):
|
for idx, token in enumerate(tokens):
|
||||||
if token[0] == "{":
|
if token[0] == "{" or token[0] == "[":
|
||||||
to_restore.append(token)
|
to_restore.append(token)
|
||||||
# Emojis aren't touched by the translator and retain their position 😎
|
# Emojis aren't touched by the translator and retain their position 😎
|
||||||
tokens[idx] = "🔠"
|
tokens[idx] = "🔠"
|
||||||
|
Reference in New Issue
Block a user