Skip to content

Commit 6fa5ece

Browse files
committed
Call msgfmt to build i18n files
1 parent 8f60c80 commit 6fa5ece

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

setup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from os.path import join
55
import sys
66
import os
7+
import glob
8+
import pathlib
9+
import subprocess
710

811
def get_version(fname='formalchemy/__init__.py'):
912
with open(fname) as f:
@@ -22,6 +25,20 @@ def read(filename):
2225
'\n\n' +\
2326
read('CHANGELOG.rst')
2427

28+
PO_FILES = 'i18n_resources/*/LC_MESSAGES/formalchemy.po'
29+
30+
def create_mo_files():
31+
mo_files = []
32+
prefix = 'formalchemy'
33+
34+
for po_path in glob.glob(str(pathlib.Path(prefix) / PO_FILES)):
35+
mo = pathlib.Path(po_path.replace('.po', '.mo'))
36+
37+
subprocess.run(['msgfmt', '-o', str(mo), po_path], check=True)
38+
mo_files.append(str(mo.relative_to(prefix)))
39+
40+
return mo_files
41+
2542
setup(name='FormAlchemy',
2643
license='MIT License',
2744
version=get_version(),
@@ -36,7 +53,7 @@ def read(filename):
3653
'ext/pylons/*.mako', 'ext/pylons/resources/*.css', 'ext/pylons/resources/*.png',
3754
'tests/data/mako/*.mako', 'tests/data/genshi/*.html',
3855
'paster_templates/pylons_fa/+package+/*/*_tmpl',
39-
]},
56+
] + create_mo_files()},
4057
include_package_data=True,
4158
classifiers=[
4259
'Development Status :: 5 - Production/Stable',

0 commit comments

Comments
 (0)