intltool

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.

waflib.Tools.intltool.feature(*k)

Decorator that registers a task generator method that will be executed when the object attribute feature contains the corresponding key(s):

from waflib.TaskGen 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

waflib.Tools.intltool.before_method(*k)[source]

Decorator that registera 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

waflib.Tools.intltool.taskgen_method(func)

Decorator that registers 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

waflib.Tools.intltool.error(*k, **kw)[source]

Wrap logging.errors, adds the stack trace when the verbosity level waflib.Logs.verbose ≥ 2

waflib.Tools.intltool.conf(f)

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

waflib.Tools.intltool.ensure_localedir(self)[source]

Task generator method

Expands LOCALEDIR from DATAROOTDIR/locale if possible, or falls back to PREFIX/share/locale

waflib.Tools.intltool.apply_intltool_in_f(self)[source]

Task generator method

Creates 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
  • podir (string) – location of the .po files

  • source (list of string) – source files to process

  • style (string) – the intltool-merge mode of operation, can be one of the following values: ba, desktop, keys, quoted, quotedxml, rfc822deb, schemas and xml. See the intltool-merge man page for more information about supported modes of operation.

  • flags (list of string) – compilation flags (“-quc” by default)

  • install_path (string) – installation path

Feature

intltool_in

waflib.Tools.intltool.apply_intltool_po(self)[source]

Task generator method

Creates 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
  • podir (string) – directory of the .po files

  • appname (string) – name of the application

  • install_path (string) – installation directory

The file LINGUAS must be present in the directory pointed by podir and list the translation files to process.

Feature

intltool_po

class waflib.Tools.intltool.po(*k, **kw)[source]

Compiles .po files into .gmo files

color = 'BLUE'

Color for the console display, see waflib.Logs.colors_lst

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'${MSGFMT} -o ${TGT} ${SRC}'

String representing an additional hash for the class representation

orig_run_str = '${MSGFMT} -o ${TGT} ${SRC}'
vars = ['MSGFMT']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

class waflib.Tools.intltool.intltool(*k, **kw)[source]

Calls intltool-merge to update translation files

color = 'BLUE'

Color for the console display, see waflib.Logs.colors_lst

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'${INTLTOOL} ${INTLFLAGS} ${INTLCACHE_ST:INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}'

String representing an additional hash for the class representation

orig_run_str = '${INTLTOOL} ${INTLFLAGS} ${INTLCACHE_ST:INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}'
vars = ['INTLCACHE', 'INTLCACHE_ST', 'INTLFLAGS', 'INTLPODIR', 'INTLTOOL']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

waflib.Tools.intltool.find_msgfmt(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Detects msgfmt and sets the MSGFMT variable

waflib.Tools.intltool.find_intltool_merge(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Detects intltool-merge

waflib.Tools.intltool.configure(conf)[source]

Detects the program msgfmt and set conf.env.MSGFMT. Detects 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.

Features defined in this module: