def run(self):
po_dir = os.path.join(os.path.dirname(os.curdir), 'po')
for path, names, filenames in os.walk(po_dir):
for f in filenames:
if f.endswith('.po'):
lang = f[:len(f) - 3]
src = os.path.join(path, f)
dest_path = os.path.join('build', 'locale-langpack',
lang, 'LC_MESSAGES')
dest = os.path.join(dest_path, COMPILED_LANGUAGE_FILE)
if not os.path.exists(dest_path):
os.makedirs(dest_path)
if not os.path.exists(dest):
print('Compiling %s -> %s' % (src, dest))
msgfmt_cmd = 'msgfmt {} -o {}'.format(src, dest)
subprocess.call(msgfmt_cmd, shell=True)
else:
src_mtime = os.stat(src)[8]
dest_mtime = os.stat(dest)[8]
if src_mtime > dest_mtime:
print('Compiling %s -> %s' % (src, dest))
msgfmt_cmd = 'msgfmt {} -o {}'.format(src, dest)
subprocess.call(msgfmt_cmd, shell=True)
评论列表
文章目录