lang-check: handle backslash sequences
This commit is contained in:
parent
27d7edae10
commit
201d2a2434
@ -48,6 +48,12 @@ def print_truncated(text, cols):
|
|||||||
print(' |' + prefix + '|' + suffix)
|
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):
|
def parse_txt(lang, no_warning):
|
||||||
"""Parse txt file and check strings to display definition."""
|
"""Parse txt file and check strings to display definition."""
|
||||||
if lang == "en":
|
if lang == "en":
|
||||||
@ -94,6 +100,11 @@ def parse_txt(lang, no_warning):
|
|||||||
if translation == '\\x00':
|
if translation == '\\x00':
|
||||||
# crude hack to handle intentionally-empty translations
|
# crude hack to handle intentionally-empty translations
|
||||||
translation = ''
|
translation = ''
|
||||||
|
|
||||||
|
# handle backslash sequences
|
||||||
|
source = unescape(source)
|
||||||
|
translation = unescape(translation)
|
||||||
|
|
||||||
#print (translation) #Debug
|
#print (translation) #Debug
|
||||||
wrapped_source = list(textwrap.TextWrapper(width=cols).wrap(source))
|
wrapped_source = list(textwrap.TextWrapper(width=cols).wrap(source))
|
||||||
rows_count_source = len(wrapped_source)
|
rows_count_source = len(wrapped_source)
|
||||||
|
Loading…
Reference in New Issue
Block a user