mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
Make po statistics script work with Python 3.
This commit is contained in:
parent
cab4302377
commit
d3f6ec003d
@ -37,6 +37,8 @@ ommitted = ('en.po')
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import codecs
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
# Reset the locale
|
# Reset the locale
|
||||||
import locale
|
import locale
|
||||||
@ -69,7 +71,7 @@ def read_pofile(pofile):
|
|||||||
""" Read the header of the pofile and return it as a dictionary"""
|
""" Read the header of the pofile and return it as a dictionary"""
|
||||||
header = {}
|
header = {}
|
||||||
read_header = False
|
read_header = False
|
||||||
for line in open(pofile):
|
for line in codecs.open(pofile, encoding='utf8'):
|
||||||
line = line[:-1]
|
line = line[:-1]
|
||||||
if line[:5] == 'msgid':
|
if line[:5] == 'msgid':
|
||||||
if read_header:
|
if read_header:
|
||||||
@ -112,12 +114,13 @@ def run_msgfmt(pofile):
|
|||||||
prop["email"] = prop["email"].replace(".", " ! ")
|
prop["email"] = prop["email"].replace(".", " ! ")
|
||||||
translator = header['Last-Translator'].split('<')[0].strip()
|
translator = header['Last-Translator'].split('<')[0].strip()
|
||||||
try:
|
try:
|
||||||
prop["translator"] = translator.decode(charset).encode('ascii','xmlcharrefreplace')
|
prop["translator"] = translator.encode('ascii','xmlcharrefreplace')
|
||||||
except LookupError:
|
except LookupError:
|
||||||
prop["translator"] = translator
|
prop["translator"] = translator
|
||||||
|
|
||||||
p_in, p_out = os.popen4("msgfmt --statistics -o %s %s" % (gmofile, pofile))
|
P = Popen("msgfmt --statistics -o %s %s" % (gmofile, pofile),
|
||||||
extract_number(p_out.readline(),
|
shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
|
||||||
|
extract_number(P.stdout.readline().decode(),
|
||||||
('translated', 'fuzzy', 'untranslated'),
|
('translated', 'fuzzy', 'untranslated'),
|
||||||
prop)
|
prop)
|
||||||
return """
|
return """
|
||||||
|
Loading…
Reference in New Issue
Block a user