mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Also generate ISO 639 POT file automatically from the db. Fixes #1860856 [String not found in Transifex](https://bugs.launchpad.net/calibre/+bug/1860856)
This commit is contained in:
parent
e2b4fa251c
commit
d51fa29acd
@ -91,6 +91,28 @@ class POT(Command): # {{{
|
|||||||
|
|
||||||
return '\n'.join(ans)
|
return '\n'.join(ans)
|
||||||
|
|
||||||
|
def get_iso639_strings(self):
|
||||||
|
self.info('Generating translation template for iso639')
|
||||||
|
src = self.j(self.d(self.SRC), 'setup', 'iso_639-3.json')
|
||||||
|
if not os.path.exists(src):
|
||||||
|
raise Exception(src + ' does not exist')
|
||||||
|
with open(src, 'rb') as f:
|
||||||
|
root = json.load(f)
|
||||||
|
entries = root['639-3']
|
||||||
|
ans = []
|
||||||
|
for x in sorted(entries, key=lambda x:(x.get('name') or '').lower()):
|
||||||
|
name = x.get('name')
|
||||||
|
if name:
|
||||||
|
ans.append(u'msgid "{}"'.format(name))
|
||||||
|
ans.append('msgstr ""')
|
||||||
|
ans.append('')
|
||||||
|
pot = self.pot_header() + '\n\n' + '\n'.join(ans)
|
||||||
|
dest = self.j(self.TRANSLATIONS, 'iso_639', 'iso_639_3.pot')
|
||||||
|
with open(dest, 'wb') as f:
|
||||||
|
f.write(pot.encode('utf-8'))
|
||||||
|
self.upload_pot(resource='iso639')
|
||||||
|
self.git(['add', dest])
|
||||||
|
|
||||||
def get_content_server_strings(self):
|
def get_content_server_strings(self):
|
||||||
self.info('Generating translation template for content_server')
|
self.info('Generating translation template for content_server')
|
||||||
from calibre import walk
|
from calibre import walk
|
||||||
@ -182,6 +204,7 @@ class POT(Command): # {{{
|
|||||||
|
|
||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
require_git_master()
|
require_git_master()
|
||||||
|
self.get_iso639_strings()
|
||||||
self.get_website_strings()
|
self.get_website_strings()
|
||||||
self.get_content_server_strings()
|
self.get_content_server_strings()
|
||||||
self.get_user_manual_docs()
|
self.get_user_manual_docs()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user