Support for translation tools such as msgfmt and intltool
Usage:
def configure(conf):
conf.load('gnu_dirs intltool')
def build(bld):
# process the .po files into .gmo files, and install them in LOCALEDIR
bld(features='intltool_po', appname='myapp', podir='po', install_path="${LOCALEDIR}")
# process an input file, substituting the translations from the po dir
bld(
features = "intltool_in",
podir = "../po",
style = "desktop",
flags = ["-u"],
source = 'kupfer.desktop.in',
install_path = "${DATADIR}/applications",
)
Usage of the waflib.Tools.gnu_dirs is recommended, but not obligatory.
Task generator method
Create tasks to translate files by intltool-merge:
def build(bld):
bld(
features = "intltool_in",
podir = "../po",
style = "desktop",
flags = ["-u"],
source = 'kupfer.desktop.in',
install_path = "${DATADIR}/applications",
)
Parameters: |
|
---|
ba, desktop, keys, quoted, quotedxml, rfc822deb, schemas and xml. See the intltool-merge man page for more information about supported modes of operation. :type style: string :param flags: compilation flags (“-quc” by default) :type flags: list of string :param install_path: installation path :type install_path: string
Feature: | intltool_in |
---|
Task generator method
Create tasks to process po files:
def build(bld):
bld(features='intltool_po', appname='myapp', podir='po', install_path="${LOCALEDIR}")
The relevant task generator arguments are:
Parameters: |
|
---|
The file LINGUAS must be present in the directory pointed by podir and list the translation files to process.
Feature: | intltool_po |
---|
Bases: waflib.Task.Task
Compile .po files into .gmo files
Bases: waflib.Task.Task
Let intltool-merge translate an input file
Configuration Method bound to waflib.Configure.ConfigurationContext
Configuration Method bound to waflib.Configure.ConfigurationContext
Detect the program msgfmt and set conf.env.MSGFMT. Detect the program intltool-merge and set conf.env.INTLTOOL. It is possible to set INTLTOOL in the environment, but it must not have spaces in it:
$ INTLTOOL="/path/to/the program/intltool" waf configure
If a C/C++ compiler is present, execute a compilation test to find the header locale.h.
Decorator: attach new configuration functions to waflib.Build.BuildContext and waflib.Configure.ConfigurationContext. The methods bound will accept a parameter named ‘mandatory’ to disable the configuration errors:
def configure(conf):
conf.find_program('abc', mandatory=False)
Parameters: | f (function) – method to bind |
---|
Decorator: register a method as a task generator method. The function must accept a task generator as first parameter:
from waflib.TaskGen import taskgen_method
@taskgen_method
def mymethod(self):
pass
Parameters: | func (function) – task generator method to add |
---|---|
Return type: | function |
Decorator: register a task generator method that will be executed when the object attribute ‘feature’ contains the corresponding key(s):
from waflib.Task import feature
@feature('myfeature')
def myfunction(self):
print('that is my feature!')
def build(bld):
bld(features='myfeature')
Parameters: | k (list of string) – feature names |
---|
Decorator: register a task generator method which will be executed before the functions of given name(s):
from waflib.TaskGen import feature, before
@feature('myfeature')
@before_method('fun2')
def fun1(self):
print('feature 1!')
@feature('myfeature')
def fun2(self):
print('feature 2!')
def build(bld):
bld(features='myfeature')
Parameters: | k (list of string) – method names |
---|
Wrap logging.errors, display the origin of the message when ‘-vv’ is set
Features defined in this module: