forked from kivy/kivy-translations
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.py
executable file
·48 lines (36 loc) · 1.07 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
'''
Build script for compiling kivy translation
===========================================
'''
from os import listdir, makedirs
from os.path import dirname, join, exists, isdir
from subprocess import Popen
curdir = dirname(__file__)
sources_dir = join(curdir, 'sources')
compiled_dir = join(curdir, 'compiled')
for lang in listdir(sources_dir):
if lang == 'templates':
continue
lang_dir = join(sources_dir, lang)
if not isdir(lang_dir):
continue
print 'Compile lang %s...' % lang
dest_dir = join(compiled_dir, lang, 'LC_MESSAGES')
if not exists(dest_dir):
makedirs(dest_dir)
counter = 0
for filename in listdir(lang_dir):
filename, ext = filename.rsplit('.', 1)
if ext!= 'po':
continue
mo_filename = '%s.mo' % filename
po_filename = '%s.po' % filename
cmd = 'msgfmt "%s" -o "%s"' % (
join(lang_dir, po_filename),
join(dest_dir, mo_filename))
# XXX no error check ?
print '\rAnalyse', '%-50s' % filename,
Popen(cmd, shell=True).communicate()
counter += 1
print '\rLang %s done. (%d files)' % (lang, counter) + ' ' * 50