Be more strict when checking translation lenght

Strip quotes immediately so that we can measure strings easily.
For single-line strings, check the translation lenght correctly.
This commit is contained in:
Yuri D'Elia 2021-04-23 12:18:50 +02:00
parent a9f0ff441d
commit 8b5d01e3b1

View File

@ -36,20 +36,20 @@ def parse_txt(lang, no_warning):
while True: while True:
comment = src.readline().split(' ') comment = src.readline().split(' ')
#print (comment) #Debug #print (comment) #Debug
source = src.readline()[:-1] source = src.readline()[:-1].strip('"')
#print (source) #Debug #print (source) #Debug
translation = src.readline()[:-1] translation = src.readline()[:-1].strip('"')
#print (translation) #Debug #print (translation) #Debug
#Wrap text to 20 chars and rows #Wrap text to 20 chars and rows
wrapper = textwrap.TextWrapper(width=20) wrapper = textwrap.TextWrapper(width=20)
#wrap original/source #wrap original/source
rows_count_source = 0 rows_count_source = 0
for line in wrapper.wrap(source.strip('"')): for line in wrapper.wrap(source):
rows_count_source += 1 rows_count_source += 1
#print (line) #Debug #print (line) #Debug
#wrap translation #wrap translation
rows_count_translation = 0 rows_count_translation = 0
for line in wrapper.wrap(translation.strip('"')): for line in wrapper.wrap(translation):
rows_count_translation += 1 rows_count_translation += 1
#print (line) #Debug #print (line) #Debug
#End wrap text #End wrap text
@ -76,8 +76,10 @@ def parse_txt(lang, no_warning):
if rows is None: if rows is None:
rows = 1 rows = 1
if rows_count_translation > rows_count_source and rows_count_translation > rows: if (rows_count_translation > rows_count_source and rows_count_translation > rows) or \
print(red("[E]: Text %s is longer then definition on line %d rows diff=%d\n[EN]:Text %s cols=%d rows=%d\n" % (translation, lines, rows_count_translation-rows, source, cols, rows))) (rows == 1 and len(translation) > cols):
print(red('[E]: Text "%s" is longer then definition on line %d (rows diff=%d)\n'
'[EN]:Text "%s" cols=%d rows=%d\n' % (translation, lines, rows_count_translation-rows, source, cols, rows)))
if len(src.readline()) != 1: # empty line if len(src.readline()) != 1: # empty line