source: waflib/Tools/intltool.py @ 0fa325b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 0fa325b was 0fa325b, checked in by Paul Brossier <piem@piem.org>, 11 years ago

waf: unpack

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#! /usr/bin/env python
2# encoding: utf-8
3# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
4
5import os,re
6from waflib import Configure,TaskGen,Task,Utils,Runner,Options,Build,Logs
7import waflib.Tools.ccroot
8from waflib.TaskGen import feature,before_method
9from waflib.Logs import error
10@before_method('process_source')
11@feature('intltool_in')
12def apply_intltool_in_f(self):
13        try:self.meths.remove('process_source')
14        except ValueError:pass
15        if not self.env.LOCALEDIR:
16                self.env.LOCALEDIR=self.env.PREFIX+'/share/locale'
17        for i in self.to_list(self.source):
18                node=self.path.find_resource(i)
19                podir=getattr(self,'podir','po')
20                podirnode=self.path.find_dir(podir)
21                if not podirnode:
22                        error("could not find the podir %r"%podir)
23                        continue
24                cache=getattr(self,'intlcache','.intlcache')
25                self.env['INTLCACHE']=os.path.join(self.path.bldpath(),podir,cache)
26                self.env['INTLPODIR']=podirnode.bldpath()
27                self.env['INTLFLAGS']=getattr(self,'flags',['-q','-u','-c'])
28                task=self.create_task('intltool',node,node.change_ext(''))
29                inst=getattr(self,'install_path','${LOCALEDIR}')
30                if inst:
31                        self.bld.install_files(inst,task.outputs)
32@feature('intltool_po')
33def apply_intltool_po(self):
34        try:self.meths.remove('process_source')
35        except ValueError:pass
36        if not self.env.LOCALEDIR:
37                self.env.LOCALEDIR=self.env.PREFIX+'/share/locale'
38        appname=getattr(self,'appname','set_your_app_name')
39        podir=getattr(self,'podir','')
40        inst=getattr(self,'install_path','${LOCALEDIR}')
41        linguas=self.path.find_node(os.path.join(podir,'LINGUAS'))
42        if linguas:
43                file=open(linguas.abspath())
44                langs=[]
45                for line in file.readlines():
46                        if not line.startswith('#'):
47                                langs+=line.split()
48                file.close()
49                re_linguas=re.compile('[-a-zA-Z_@.]+')
50                for lang in langs:
51                        if re_linguas.match(lang):
52                                node=self.path.find_resource(os.path.join(podir,re_linguas.match(lang).group()+'.po'))
53                                task=self.create_task('po',node,node.change_ext('.mo'))
54                                if inst:
55                                        filename=task.outputs[0].name
56                                        (langname,ext)=os.path.splitext(filename)
57                                        inst_file=inst+os.sep+langname+os.sep+'LC_MESSAGES'+os.sep+appname+'.mo'
58                                        self.bld.install_as(inst_file,task.outputs[0],chmod=getattr(self,'chmod',Utils.O644),env=task.env)
59        else:
60                Logs.pprint('RED',"Error no LINGUAS file found in po directory")
61class po(Task.Task):
62        run_str='${MSGFMT} -o ${TGT} ${SRC}'
63        color='BLUE'
64class intltool(Task.Task):
65        run_str='${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}'
66        color='BLUE'
67def configure(conf):
68        conf.find_program('msgfmt',var='MSGFMT')
69        conf.find_perl_program('intltool-merge',var='INTLTOOL')
70        prefix=conf.env.PREFIX
71        datadir=conf.env.DATADIR
72        if not datadir:
73                datadir=os.path.join(prefix,'share')
74        conf.define('LOCALEDIR',os.path.join(datadir,'locale').replace('\\','\\\\'))
75        conf.define('DATADIR',datadir.replace('\\','\\\\'))
76        if conf.env.CC or conf.env.CXX:
77                conf.check(header_name='locale.h')
Note: See TracBrowser for help on using the repository browser.