Split website and changelog translations

This commit is contained in:
Kovid Goyal 2019-12-25 09:58:58 +05:30
parent aca252eacf
commit ff5039dd31
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -139,17 +139,23 @@ class POT(Command): # {{{
self.info('Generating translation template for website') self.info('Generating translation template for website')
self.wn_path = os.path.expanduser('~/work/srv/main/static/generate.py') self.wn_path = os.path.expanduser('~/work/srv/main/static/generate.py')
data = subprocess.check_output([self.wn_path, '--pot', '/tmp/wn']) data = subprocess.check_output([self.wn_path, '--pot', '/tmp/wn'])
bdir = os.path.join(self.TRANSLATIONS, 'website') data = json.loads(data)
if not os.path.exists(bdir):
os.makedirs(bdir) def do(name):
pot = os.path.join(bdir, 'website.pot') messages = data[name]
with open(pot, 'wb') as f: bdir = os.path.join(self.TRANSLATIONS, name)
f.write(self.pot_header().encode('utf-8')) if not os.path.exists(bdir):
f.write(b'\n') os.makedirs(bdir)
f.write(data) pot = os.path.abspath(os.path.join(bdir, name + '.pot'))
self.info('Website translations:', os.path.abspath(pot)) with open(pot, 'wb') as f:
self.upload_pot(resource='website') f.write(self.pot_header().encode('utf-8'))
self.git(['add', os.path.abspath(pot)]) f.write(b'\n')
f.write('\n'.join(messages).encode('utf-8'))
self.upload_pot(resource=name)
self.git(['add', pot])
do('website')
do('changelog')
def pot_header(self, appname=__appname__, version=__version__): def pot_header(self, appname=__appname__, version=__version__):
return textwrap.dedent('''\ return textwrap.dedent('''\
@ -427,7 +433,7 @@ class Translations(POT): # {{{
if self.iso639_errors: if self.iso639_errors:
for err in self.iso639_errors: for err in self.iso639_errors:
print (err) print(err)
raise SystemExit(1) raise SystemExit(1)
dest = self.stats dest = self.stats