updated panorama localization
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
import vdf
|
||||
import sys
|
||||
|
||||
def main(english_keyfile: str, chinese_keyfile: str, output_file: str):
|
||||
chinese = vdf.load(open(chinese_keyfile, encoding='utf-16-le'), mapper=vdf.VDFDict)['lang']['Tokens']
|
||||
english = vdf.load(open(english_keyfile), mapper=vdf.VDFDict)['lang']['Tokens']
|
||||
output = vdf.VDFDict()
|
||||
output['lang'] = vdf.VDFDict()
|
||||
output['lang']['Language'] = "english"
|
||||
output['lang']['Tokens'] = vdf.VDFDict()
|
||||
output_tokens = output['lang']['Tokens']
|
||||
for key in chinese:
|
||||
#print(key)
|
||||
if key in english.keys():
|
||||
output_tokens[key] = english[key]
|
||||
def copy_kvs(english_keys: vdf.VDFDict, chinese_keys: vdf.VDFDict, output: vdf.VDFDict):
|
||||
for key in chinese_keys:
|
||||
if not isinstance(chinese_keys[key], str):
|
||||
output[key] = vdf.VDFDict()
|
||||
copy_kvs(english_keys[key], chinese_keys[key], output[key])
|
||||
elif key in english_keys and len(english_keys[key]) > 0:
|
||||
output[key] = english_keys[key]
|
||||
else:
|
||||
output_tokens[key] = chinese[key]
|
||||
output[key] = chinese_keys[key]
|
||||
|
||||
def main(english_keyfile: str, chinese_keyfile: str, output_file: str, chinese_encoding: str, english_encoding: str):
|
||||
if chinese_encoding is None:
|
||||
chinese_encoding = 'utf8'
|
||||
if english_encoding is None:
|
||||
english_encoding = 'utf8'
|
||||
chinese = vdf.load(open(chinese_keyfile, encoding=chinese_encoding), mapper=vdf.VDFDict)
|
||||
english = vdf.load(open(english_keyfile, encoding=english_encoding), mapper=vdf.VDFDict)
|
||||
output = vdf.VDFDict()
|
||||
copy_kvs(english, chinese, output)
|
||||
vdf.dump(output, open(output_file, 'w'),pretty=True)
|
||||
args = sys.argv[1:]
|
||||
main(args[0], args[1], args[2])
|
||||
main(args[0], args[1], args[2], args[3], args[4])
|
||||
0
tools/test.out
Normal file
0
tools/test.out
Normal file
Reference in New Issue
Block a user