|
@@ -1,7 +1,6 @@
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -13,12 +12,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
"""Check lang files."""
|
|
|
from argparse import ArgumentParser
|
|
|
from traceback import print_exc
|
|
|
-from sys import stdout, stderr
|
|
|
+from sys import stdout, stderr, exit
|
|
|
import textwrap
|
|
|
import re
|
|
|
|
|
@@ -99,7 +112,6 @@ def ign_char_first(c):
|
|
|
def ign_char_last(c):
|
|
|
return c.isalnum() or c in {'.', "'"}
|
|
|
|
|
|
-
|
|
|
def parse_txt(lang, no_warning, warn_empty):
|
|
|
"""Parse txt file and check strings to display definition."""
|
|
|
if lang == "en":
|
|
@@ -112,9 +124,15 @@ def parse_txt(lang, no_warning, warn_empty):
|
|
|
lines = 1
|
|
|
with open(file_path) as src:
|
|
|
while True:
|
|
|
- comment = src.readline().split(' ')
|
|
|
-
|
|
|
-
|
|
|
+ message = src.readline()
|
|
|
+
|
|
|
+
|
|
|
+ if (message[0:4] != '#MSG'):
|
|
|
+ print(red("[E]: Critical syntax error: 1st line doesn't start with #MSG on line %d" % lines))
|
|
|
+ print(red(message))
|
|
|
+ exit(1)
|
|
|
+
|
|
|
+ comment = message.split(' ')
|
|
|
|
|
|
cols = None
|
|
|
rows = None
|
|
@@ -140,12 +158,46 @@ def parse_txt(lang, no_warning, warn_empty):
|
|
|
print(yellow("[W]: Multiple rows with odd number of columns on line %d" % lines))
|
|
|
|
|
|
|
|
|
- source = src.readline()[:-1].strip('"')
|
|
|
+ source = src.readline()[:-1]
|
|
|
+
|
|
|
+ if (source[0]!="\""):
|
|
|
+ print(red('[E]: Critical syntax error: Missing " at beginning of message in source on line %d' % lines))
|
|
|
+ print(red(source))
|
|
|
+ exit(1)
|
|
|
+ if (source[-1]=="\""):
|
|
|
+ source = source.strip('"')
|
|
|
+ else:
|
|
|
+ print(red('[E]: Critical syntax error: Missing " at end of message in source on line %d' % lines))
|
|
|
+ print(red(source))
|
|
|
+ exit(1)
|
|
|
|
|
|
- translation = src.readline()[:-1].strip('"')
|
|
|
+ translation = src.readline()[:-1]
|
|
|
+
|
|
|
+ if (translation[0]!="\""):
|
|
|
+ print(red('[E]: Critical syntax error: Missing " at beginning of message in translation on line %d' % lines))
|
|
|
+ print(red(translation))
|
|
|
+ exit(1)
|
|
|
+ if (translation[-1]=="\""):
|
|
|
+
|
|
|
+ translation = translation.strip('"')
|
|
|
+ else:
|
|
|
+ print(red('[E]: Critical syntax error: Missing " at end of message in translation on line %d' % lines))
|
|
|
+ print(red(translation))
|
|
|
+ exit(1)
|
|
|
+
|
|
|
if translation == '\\x00':
|
|
|
|
|
|
translation = ''
|
|
|
+
|
|
|
+ if source.isascii() == False:
|
|
|
+ print(red('[E]: Critical syntax: Non ascii chars found on line %d' % lines))
|
|
|
+ print(red(source))
|
|
|
+ exit(1)
|
|
|
+
|
|
|
+ if translation.isascii() == False:
|
|
|
+ print(red('[E]: Critical syntax: Non ascii chars found on line %d' % lines))
|
|
|
+ print(red(translation))
|
|
|
+ exit(1)
|
|
|
|
|
|
|
|
|
source = unescape(source)
|
|
@@ -232,8 +284,8 @@ def parse_txt(lang, no_warning, warn_empty):
|
|
|
print_source_translation(source, translation,
|
|
|
wrapped_source, wrapped_translation,
|
|
|
rows, cols)
|
|
|
-
|
|
|
if len(src.readline()) != 1:
|
|
|
+ print(red('[E]: Critical Syntax error: Missing empty line between messages between lines: %d and %d' % (lines+3,lines+4)))
|
|
|
break
|
|
|
lines += 4
|
|
|
print(green("End %s lang-check" % lang))
|