File: SConstruct

package info (click to toggle)
globs 0.2.0~svn50-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 1,192 kB
  • ctags: 461
  • sloc: ansic: 2,225; python: 1,727; makefile: 93; sh: 2
file content (51 lines) | stat: -rw-r--r-- 1,545 bytes parent folder | download | duplicates (2)
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
49
50
51
import os, SCons

# import variables
try:
	Import('locale_dir')
except SCons.Errors.UserError:
	# Install directory
	root = ARGUMENTS.get('root', '/')
	prefix = ARGUMENTS.get('prefix', 'usr/local')
	if root != '' and prefix != '': # not defaults
		if prefix[0] == '/':
			prefix = prefix[1:]
	locale_dir = os.path.join(root, prefix, 'share/locale')

# create environment
env = Environment()
pkg = 'globs'
langs = ('it', 'de', 'tr', 'fr', 'es', 'sv')

# defining helpers and builders
def pot_helper():
	args = [ 'intltool-update', '--pot', '--gettext-package=' + pkg]
	print 'Updating ' + pkg + '.pot'
	return os.spawnvp(os.P_WAIT, 'intltool-update', args)

def po_helper(po, pot):
	args = ['msgmerge', '--update', po, pot]
	print 'Updating ' + po
	return os.spawnvp(os.P_WAIT, 'msgmerge', args)

def mo_builder(target, source, env):
	potfile = os.path.join(os.path.dirname(os.path.dirname(source[0].get_path())), pkg + '.pot')
	po_helper(source[0].get_path(), potfile)
	args = ['msgfmt', '-c', '-o', target[0].get_path(), source[0].get_path()]
	return os.spawnvp(os.P_WAIT, 'msgfmt', args)

mo_bld = Builder(action = mo_builder)
env.Append (BUILDERS = {'MoBuild' : mo_bld})

# print building message
if not env.GetOption('clean'):
	print ":: Building binary message catalogs"
	pot_helper()

for x in langs:
	catalog = env.MoBuild(os.path.join(x, 'LC_MESSAGES/%s.mo' % pkg), os.path.join(x, x + '.po'))
	# Install
	if locale_dir != '':
		dest = os.path.join(locale_dir, x, 'LC_MESSAGES')
		env.Install(dest, catalog)
		env.Alias('install', dest)