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",
                flags     = ["-d", "-q", "-u", "-c"],
                source    = 'kupfer.desktop.in',
                install_path = "${DATADIR}/applications",
        )

Usage of the waflib.Tools.gnu_dirs is recommended, but not obligatory.

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

Task generator method

Create tasks to translate files by intltool-merge:

def build(bld):
        bld(
                features  = "intltool_in",
                podir     = "../po",
                flags     = ["-d", "-q", "-u", "-c"],
                source    = 'kupfer.desktop.in',
                install_path = "${DATADIR}/applications",
        )
Parameters:
  • podir (string) – location of the .po files
  • source (list of string) – source files to process
  • 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

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:
  • 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]

Bases: waflib.Task.Task

Compile .po files into .gmo files

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

Bases: waflib.Task.Task

Let intltool-merge translate an input file

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

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.

waflib.Tools.intltool.feature(*k)

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
waflib.Tools.intltool.before_method(*k)

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
waflib.Tools.intltool.error(*k, **kw)

Wrap logging.errors, display the origin of the message when ‘-vv’ is set

Features defined in this module:

Previous topic

gnu_dirs

Next topic

lua

This Page