lang-check: attempt at spotting short translations

This commit is contained in:
Yuri D'Elia 2021-04-23 23:08:02 +02:00
parent 68fc2c71bb
commit 5f0f6d740f

View File

@ -168,6 +168,22 @@ def parse_txt(lang, no_warning):
print_wrapped(wrapped_translation, rows, cols)
print()
# Short translation
if not no_warning and len(source) > 0 and len(translation) > 0:
if len(translation.strip()) < len(source.strip()) / 2:
print(yellow('[W]: Short translation on line %d:' % (lines)))
if rows == 1:
print(yellow(' source text:'))
print_truncated(source, cols)
print(yellow(' translated text:'))
print_truncated(translation, cols)
else:
print(yellow(' source text:'))
print_wrapped(wrapped_source, rows, cols)
print(yellow(' translated text:'))
print_wrapped(wrapped_translation, rows, cols)
print()
if len(src.readline()) != 1: # empty line
break
lines += 4