瀏覽代碼

lang: Improve invalid row/column count checks

Yuri D'Elia 2 年之前
父節點
當前提交
0572b1c648
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      lang/lang-check.py

+ 9 - 5
lang/lang-check.py

@@ -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 no_warning and known_msgid:
+    if not cols:
+        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)
-    if rows is None:
+        cols = len(LCD_WIDTH)
+    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))