lang: Improve invalid row/column count checks
This commit is contained in:
parent
671cd70af7
commit
0572b1c648
1 changed files with 9 additions and 5 deletions
|
@ -42,6 +42,7 @@ from lib import charset as cs
|
||||||
from lib.io import load_map
|
from lib.io import load_map
|
||||||
|
|
||||||
COLORIZE = (stdout.isatty() and os.getenv("TERM", "dumb") != "dumb") or os.getenv('NO_COLOR') == "0"
|
COLORIZE = (stdout.isatty() and os.getenv("TERM", "dumb") != "dumb") or os.getenv('NO_COLOR') == "0"
|
||||||
|
LCD_WIDTH = 20
|
||||||
|
|
||||||
def color_maybe(color_attr, text):
|
def color_maybe(color_attr, text):
|
||||||
if COLORIZE:
|
if COLORIZE:
|
||||||
|
@ -161,15 +162,18 @@ def check_translation(entry, msgids, is_pot, no_warning, no_suggest, warn_empty,
|
||||||
print(red(" definition: " + meta))
|
print(red(" definition: " + meta))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if cols is None and rows is None:
|
if not cols:
|
||||||
if not no_warning and known_msgid:
|
if not no_warning and known_msgid and not rows:
|
||||||
errors += 1
|
errors += 1
|
||||||
print(yellow("[W]: No usable display definition on line %d" % line))
|
print(yellow("[W]: No usable display definition on line %d" % line))
|
||||||
# probably fullscreen, guess from the message length to continue checking
|
# probably fullscreen, guess from the message length to continue checking
|
||||||
cols = len(source)
|
cols = len(LCD_WIDTH)
|
||||||
if rows is None:
|
if cols > LCD_WIDTH:
|
||||||
|
errors += 1
|
||||||
|
print(yellow("[W]: Invalid column count on line %d" % line))
|
||||||
|
if not rows:
|
||||||
rows = 1
|
rows = 1
|
||||||
elif rows > 1 and cols != 20:
|
elif rows > 1 and cols != LCD_WIDTH:
|
||||||
errors += 1
|
errors += 1
|
||||||
print(yellow("[W]: Multiple rows with odd number of columns on line %d" % line))
|
print(yellow("[W]: Multiple rows with odd number of columns on line %d" % line))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue