Fix indentation
This commit is contained in:
parent
9dc9c9c15f
commit
4c03ee943f
1 changed files with 30 additions and 30 deletions
|
@ -60,35 +60,35 @@ def indent(elem, level=0):
|
||||||
|
|
||||||
root = etree.Element('addon')
|
root = etree.Element('addon')
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(PKC_dir,
|
with open(os.path.join(PKC_dir,
|
||||||
'resources',
|
'resources',
|
||||||
'language',
|
'language',
|
||||||
'resource.language.%s' % lang,
|
'resource.language.%s' % lang,
|
||||||
'strings.po'), 'rb') as f:
|
'strings.po'), 'rb') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.strip() in addon:
|
if line.strip() in addon:
|
||||||
msg = ''
|
msg = ''
|
||||||
key = str(line.strip())
|
key = str(line.strip())
|
||||||
# Advance to the line msgstr ""
|
# Advance to the line msgstr ""
|
||||||
part = ''
|
part = ''
|
||||||
while not part.startswith('msgstr'):
|
while not part.startswith('msgstr'):
|
||||||
part = next(f)
|
part = next(f)
|
||||||
msg += part.replace('msgstr', '').replace('"', '').strip()
|
msg += part.replace('msgstr', '').replace('"', '').strip()
|
||||||
part = None
|
part = None
|
||||||
while part != '':
|
while part != '':
|
||||||
part = next(f).strip()
|
part = next(f).strip()
|
||||||
msg += part
|
msg += part
|
||||||
msg = msg.replace('"', '').replace('\r', '').replace('\n', '')
|
msg = msg.replace('"', '').replace('\r', '').replace('\n', '')
|
||||||
print(msg)
|
print(msg)
|
||||||
etree.SubElement(root,
|
etree.SubElement(root,
|
||||||
addon[key],
|
addon[key],
|
||||||
attrib={'lang': lang}).text = msg.decode('utf-8')
|
attrib={'lang': lang}).text = msg.decode('utf-8')
|
||||||
except IOError:
|
except IOError:
|
||||||
print('Missing file %s' % os.path.join(PKC_dir,
|
print('Missing file %s' % os.path.join(PKC_dir,
|
||||||
'resources',
|
'resources',
|
||||||
'language',
|
'language',
|
||||||
'resource.language.%s' % lang,
|
'resource.language.%s' % lang,
|
||||||
'strings.po'))
|
'strings.po'))
|
||||||
indent(root)
|
indent(root)
|
||||||
etree.ElementTree(root).write(tmp_file, encoding="UTF-8")
|
etree.ElementTree(root).write(tmp_file, encoding="UTF-8")
|
||||||
|
|
Loading…
Reference in a new issue