3.0 KiB
I18n module
This module provides internationalisation and localisation functionality.
Usage
To use this module, just do: i18n = import('i18n')
. The
following functions will then be available as methods on the object
with the name i18n
. You can, of course, replace the name i18n
with
anything else.
i18n.gettext()
Sets up gettext localisation so that translations are built and placed into their proper locations during install. Takes one positional argument which is the name of the gettext module.
args
: list of extra arguments to pass toxgettext
when generating the pot filedata_dirs
: (Added 0.36.0) list of directories to be set forGETTEXTDATADIRS
env var (Requires gettext 0.19.8+), used for local its fileslanguages
: list of languages that are to be generated. As of 0.37.0 this is optional and the LINGUAS file is read.preset
: (Added 0.37.0) name of a preset list of arguments, current option is'glib'
, see source for for their valueinstall
: (Added 0.43.0) if false, do not install the built translations.install_dir
: (Added 0.50.0) override default install location, default islocaledir
This function also defines targets for maintainers to use: Note: These output to the source directory
<project_id>-pot
: runsxgettext
to regenerate the pot file<project_id>-update-po
: regenerates the.po
files from current.pot
file<project_id>-gmo
: builds the translations without installing
(since 0.60.0) Returns a list containing:
- a list of built
.mo
files - the maintainer
-pot
target - the maintainer
-update-po
target
i18n.merge_file()
This merges translations into a text file using msgfmt
. See
custom_tgt
for normal keywords. In addition it accepts these keywords:
output
: same ascustom_target
but only accepts one iteminstall_dir
: same ascustom_target
but only accepts one iteminstall_tag
: same ascustom_target
but only accepts one itemdata_dirs
: (Added 0.41.0) list of directories for its files (See alsoi18n.gettext()
)po_dir
: directory containing translations, relative to current directorytype
: type of file, valid options are'xml'
(default) and'desktop'
args
: (Added 0.51.0) list of extra arguments to pass tomsgfmt
Added 0.37.0
i18n.itstool_join()
This joins translations into a XML file using itstool
. See
custom_tgt
for normal keywords. In addition it accepts these keywords:
output
: same ascustom_target
but only accepts one iteminstall_dir
: same ascustom_target
but only accepts one iteminstall_tag
: same ascustom_target
but only accepts one itemits_files
: filenames of ITS files that should be used explicitly (XML translation rules are autodetected otherwise).mo_targets
required: mo file generation targets as returned byi18n.gettext()
.
Added 0.62.0