3
# WARNING! Do not edit! http://waf.googlecode.com/svn/docs/wafbook/single.html#_obtaining_the_waf_file
6
from waflib import Configure,TaskGen,Task,Utils,Runner,Options,Build,Logs
7
import waflib.Tools.ccroot
8
from waflib.TaskGen import feature,before_method
9
from waflib.Logs import error
10
def apply_intltool_in_f(self):
11
try:self.meths.remove('process_source')
12
except ValueError:pass
13
if not self.env.LOCALEDIR:
14
self.env.LOCALEDIR=self.env.PREFIX+'/share/locale'
15
for i in self.to_list(self.source):
16
node=self.path.find_resource(i)
17
podir=getattr(self,'podir','po')
18
podirnode=self.path.find_dir(podir)
20
error("could not find the podir %r"%podir)
22
cache=getattr(self,'intlcache','.intlcache')
23
self.env['INTLCACHE']=os.path.join(self.path.bldpath(),podir,cache)
24
self.env['INTLPODIR']=podirnode.bldpath()
25
self.env['INTLFLAGS']=getattr(self,'flags',['-q','-u','-c'])
26
task=self.create_task('intltool',node,node.change_ext(''))
27
inst=getattr(self,'install_path','${LOCALEDIR}')
29
self.bld.install_files(inst,task.outputs)
30
def apply_intltool_po(self):
31
try:self.meths.remove('process_source')
32
except ValueError:pass
33
if not self.env.LOCALEDIR:
34
self.env.LOCALEDIR=self.env.PREFIX+'/share/locale'
35
appname=getattr(self,'appname','set_your_app_name')
36
podir=getattr(self,'podir','')
37
inst=getattr(self,'install_path','${LOCALEDIR}')
38
linguas=self.path.find_node(os.path.join(podir,'LINGUAS'))
40
file=open(linguas.abspath())
42
for line in file.readlines():
43
if not line.startswith('#'):
46
re_linguas=re.compile('[-a-zA-Z_@.]+')
48
if re_linguas.match(lang):
49
node=self.path.find_resource(os.path.join(podir,re_linguas.match(lang).group()+'.po'))
50
task=self.create_task('po',node,node.change_ext('.mo'))
52
filename=task.outputs[0].name
53
(langname,ext)=os.path.splitext(filename)
54
inst_file=inst+os.sep+langname+os.sep+'LC_MESSAGES'+os.sep+appname+'.mo'
55
self.bld.install_as(inst_file,task.outputs[0],chmod=getattr(self,'chmod',Utils.O644),env=task.env)
57
Logs.pprint('RED',"Error no LINGUAS file found in po directory")
59
run_str='${MSGFMT} -o ${TGT} ${SRC}'
61
class intltool(Task.Task):
62
run_str='${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}'
65
conf.find_program('msgfmt',var='MSGFMT')
66
conf.find_perl_program('intltool-merge',var='INTLTOOL')
67
prefix=conf.env.PREFIX
68
datadir=conf.env.DATADIR
70
datadir=os.path.join(prefix,'share')
71
conf.define('LOCALEDIR',os.path.join(datadir,'locale').replace('\\','\\\\'))
72
conf.define('DATADIR',datadir.replace('\\','\\\\'))
73
if conf.env.CC or conf.env.CXX:
74
conf.check(header_name='locale.h')
76
before_method('process_source')(apply_intltool_in_f)
77
feature('intltool_in')(apply_intltool_in_f)
78
feature('intltool_po')(apply_intltool_po)
b'\\ No newline at end of file'