lyx_pot.py: consider empty encoding gui name

(cherry picked from commit 43c05fe16b)
This commit is contained in:
Juergen Spitzmueller 2018-01-02 13:55:01 +01:00
parent 34097ce8f0
commit c284a1b5b3

View File

@ -601,14 +601,16 @@ def encodings_l10n(input_files, output, base):
output = io.open(output, 'w', encoding='utf_8', newline='\n') output = io.open(output, 'w', encoding='utf_8', newline='\n')
# assuming only one encodings file # assuming only one encodings file
# Encoding utf8 utf8 "Unicode (utf8)" UTF-8 variable inputenc # Encoding utf8 utf8 "Unicode (utf8)" UTF-8 variable inputenc
reg = re.compile('Encoding [\w-]+\s+[\w-]+\s+"([\w \-\(\)]+)"\s+[\w-]+\s+(fixed|variable|variableunsafe)\s+\w+.*') reg = re.compile('Encoding [\w-]+\s+[\w-]+\s+"([\w \-\(\)^"]*)"\s+["\w-]+\s+(fixed|variable|variableunsafe)\s+\w+.*')
input = io.open(input_files[0], encoding='utf_8') input = io.open(input_files[0], encoding='utf_8')
for lineno, line in enumerate(input.readlines()): for lineno, line in enumerate(input.readlines()):
if not line.startswith('Encoding'): if not line.startswith('Encoding'):
continue continue
if reg.match(line): if reg.match(line):
print(u'#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \ guiname = reg.match(line).groups()[0]
(relativePath(input_files[0], base), lineno+1, reg.match(line).groups()[0]), file=output) if guiname != "":
print(u'#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
(relativePath(input_files[0], base), lineno+1, guiname), file=output)
else: else:
print("Error: Unable to handle line:") print("Error: Unable to handle line:")
print(line) print(line)