Add comments for who is speaking
This commit is contained in:
parent
ff5ff5f1a0
commit
09158f0510
|
@ -91,6 +91,16 @@ def extract_dialog_string(dialog_line):
|
||||||
return res[1]
|
return res[1]
|
||||||
return res[0] # (what)
|
return res[0] # (what)
|
||||||
|
|
||||||
|
def extract_dialog_pers(line):
|
||||||
|
pos = 4
|
||||||
|
res = []
|
||||||
|
while pos < len(line):
|
||||||
|
if line[pos] == "\"":
|
||||||
|
res.append({'pers': line[4:pos-1]})
|
||||||
|
return res[0]
|
||||||
|
pos += 1
|
||||||
|
return {'pers': None}
|
||||||
|
|
||||||
def extract_base_string(dialog_line):
|
def extract_base_string(dialog_line):
|
||||||
res = extract_dqstrings(dialog_line)
|
res = extract_dqstrings(dialog_line)
|
||||||
if len(res) == 0:
|
if len(res) == 0:
|
||||||
|
@ -99,7 +109,7 @@ def extract_base_string(dialog_line):
|
||||||
|
|
||||||
def parse_next_block(lines):
|
def parse_next_block(lines):
|
||||||
ret = []
|
ret = []
|
||||||
block_string = {'id':None, 'source':None, 'text':None, 'translation':None}
|
block_string = {'id':None, 'source':None, 'pers':None, 'text':None, 'translation':None}
|
||||||
while len(lines) > 0:
|
while len(lines) > 0:
|
||||||
line = lines.pop()
|
line = lines.pop()
|
||||||
if is_empty(line):
|
if is_empty(line):
|
||||||
|
@ -122,7 +132,7 @@ def parse_next_block(lines):
|
||||||
break
|
break
|
||||||
elif block_string['id'] == 'strings':
|
elif block_string['id'] == 'strings':
|
||||||
# basic strings block
|
# basic strings block
|
||||||
string = {'id':None, 'source':None, 'text':None, 'translation':None}
|
string = {'id':None, 'source':None, 'pers':None, 'text':None, 'translation':None}
|
||||||
while len(lines) > 0:
|
while len(lines) > 0:
|
||||||
line = lines.pop()
|
line = lines.pop()
|
||||||
if is_empty(line):
|
if is_empty(line):
|
||||||
|
@ -138,7 +148,7 @@ def parse_next_block(lines):
|
||||||
elif line.lstrip().startswith('new '):
|
elif line.lstrip().startswith('new '):
|
||||||
string['translation'] = extract_base_string(line)['text']
|
string['translation'] = extract_base_string(line)['text']
|
||||||
ret.append(string)
|
ret.append(string)
|
||||||
string = {'id':None, 'source':None, 'text':None, 'translation':None}
|
string = {'id':None, 'source':None, 'pers':None,'text':None, 'translation':None}
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
|
@ -156,6 +166,8 @@ def parse_next_block(lines):
|
||||||
# untranslated original
|
# untranslated original
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
p = extract_dialog_pers(line)
|
||||||
|
block_string['pers'] = p['pers']
|
||||||
# dialog body
|
# dialog body
|
||||||
s = extract_dialog_string(line)
|
s = extract_dialog_string(line)
|
||||||
if s is None:
|
if s is None:
|
||||||
|
|
|
@ -76,6 +76,8 @@ msgstr ""
|
||||||
|
|
||||||
""")
|
""")
|
||||||
for s in strings:
|
for s in strings:
|
||||||
|
if s['pers'] != None and s['pers'] != '':
|
||||||
|
out.write(u'# Speaker: ' + s['pers'] + u'\n')
|
||||||
out.write(u'#: ' + s['source'] + u'\n')
|
out.write(u'#: ' + s['source'] + u'\n')
|
||||||
if occurrences[s['text']] > 1:
|
if occurrences[s['text']] > 1:
|
||||||
out.write(u'msgctxt "' + (s['id'] or s['source']) + u'"\n')
|
out.write(u'msgctxt "' + (s['id'] or s['source']) + u'"\n')
|
||||||
|
|
Loading…
Reference in a new issue