i18n: Fix translatable string extraction tool bug.

This commit is contained in:
月月
2025-07-14 15:08:40 +08:00
parent 8f3b2474d2
commit 2eff8d6db4
5 changed files with 22 additions and 10 deletions
@@ -56,11 +56,22 @@ class TranslationManager:
text = match[0] if match else ""
else:
text = match
# Decode escape characters
try:
clean_text = text.encode().decode('unicode_escape')
except:
if '\\u' in text or '\\x' in text:
clean_text = bytes(text, "utf-8").decode("unicode_escape")
else:
clean_text = (
text.replace('\\n', '\n')
.replace('\\t', '\t')
.replace('\\r', '\r')
.replace('\\"', '"')
.replace('\\\'', "'")
.replace('\\f', '\f')
.replace('\\b', '\b')
.replace('\\\\', '\\')
)
except Exception:
clean_text = text
# Clean text (remove extra whitespace)