Browse Source

lang-check: handle backslash sequences

Yuri D'Elia 3 years ago
parent
commit
201d2a2434
1 changed files with 11 additions and 0 deletions
  1. 11 0
      lang/lang-check.py

+ 11 - 0
lang/lang-check.py

@@ -48,6 +48,12 @@ def print_truncated(text, cols):
     print('   |' + prefix + '|' + suffix)
 
 
+def unescape(text):
+    if '\\' not in text:
+        return text
+    return text.encode('ascii').decode('unicode_escape')
+
+
 def parse_txt(lang, no_warning):
     """Parse txt file and check strings to display definition."""
     if lang == "en":
@@ -94,6 +100,11 @@ def parse_txt(lang, no_warning):
             if translation == '\\x00':
                 # crude hack to handle intentionally-empty translations
                 translation = ''
+
+            # handle backslash sequences
+            source = unescape(source)
+            translation = unescape(translation)
+
             #print (translation) #Debug
             wrapped_source = list(textwrap.TextWrapper(width=cols).wrap(source))
             rows_count_source = len(wrapped_source)