mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Fix twlang decode to handle context lines properly
Context line is always one line above. If we don't do this we end up with empty [Graphics] context lines in the translation files.
This commit is contained in:
parent
c3a0a5e700
commit
5ee7ffa33f
|
@ -59,12 +59,16 @@ def decode(fileobj, elements_per_key):
|
|||
data[current_key].append(index)
|
||||
if line in data:
|
||||
raise LanguageDecodeError("Key defined multiple times: " + line, fileobj.name, index)
|
||||
data[(line, current_context)] = [index]
|
||||
data[(line, current_context)] = [index - 1 if current_context else index]
|
||||
current_key = (line, current_context)
|
||||
if len(data[current_key]) != 1+elements_per_key:
|
||||
raise LanguageDecodeError("Wrong number of elements per key", fileobj.name, index)
|
||||
data[current_key].append(index+1)
|
||||
return data
|
||||
new_data = {}
|
||||
for key, value in data.items():
|
||||
if key[0]:
|
||||
new_data[key] = value
|
||||
return new_data
|
||||
|
||||
|
||||
def check_file(path):
|
||||
|
@ -78,7 +82,7 @@ def check_folder(path):
|
|||
for path2, dirs, files in os.walk(path):
|
||||
dirs.sort()
|
||||
for f in sorted(files):
|
||||
if not any(f.endswith(x) for x in ".cpp .c .h".split()):
|
||||
if not any(f.endswith(x) for x in [".cpp", ".c", ".h"]):
|
||||
continue
|
||||
for sentence in check_file(os.path.join(path2, f)):
|
||||
englishlist[sentence[1:]] = None
|
||||
|
|
Loading…
Reference in a new issue