Hatch build hook plugin for GNU gettext
Project description
Hatch Gettext
This provides a build hook plugin
for Hatch that compiles multi-lingual messages with GNU
gettext's tools msgfmt
and (optionally) translates files using
gettext's intltool-merge
.
Table of Contents
Configuration
The build hook plugin
name is gettext
.
Calling the plugin
Modify pyproject.toml
to include the plugin as a build dependency:
[build-system]
requires = ["hatchling", "hatch-gettext"]
build-backend = "hatchling.build"
Compiling messages with msgfmt
This plugin requires .mo
files be created; it also requires that the
directory storing them is within the project's base directory, and is not
equal to the project's base directory or the directory in which po
files
are sourced.
For example, for a project named myproject
, and a src layout
src/myproject
, an acceptable directory in which to store the
LC_MESSAGES/myproject.mo
files would be src/myproject/locale
[tool.hatch.build.hooks.gettext]
locale_directory = "src/myproject/locale"
Optionally, specify values for the gexttext output name and the source directory where po files are found:
[tool.hatch.build.hooks.gettext]
locale_directory = "src/myproject/locale"
i18n_name = "myproject"
po_directory = "po-files"
If i18n_name
is not specified, the name
in [project]
in the
pyproject.toml
is used. If po_directory
is not specified, the
directory po
is used.
Translating files using intltool-merge
This plugin allows for but does not mandate translating .xml
and
.desktop
files using intltool-merge
. Using
[tool.hatch.build.hooks.gettext.files]
, specify the destination directories
for the translated files on the left, and arrays of source files on the
right. For example:
[tool.hatch.build.hooks.gettext.files]
"share/applications" = ["data/net.myproject.desktop.in"]
"share/solid/actions" = ["data/kde/net.myproject.desktop.in"]
"share/metainfo" = ["data/net.myproject.metainfo.xml.in"]
Cleaning output files
The plugin includes logic to remove the files it outputs using hatch's
clean
hook. As well as individual files, any output directories created
will also be removed, as long as these directories do not contain files
created by something other than this plugin.
License
hatch-gettext
is distributed under the terms of the GPL-3.0-or-later license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hatch_gettext-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b695d61f3c134947261fe32e3239c14be35cf96840bfa8a4689282f6b000db4 |
|
MD5 | a03ca95b70316d063a20bd24ca2df783 |
|
BLAKE2b-256 | b97b2a6ab08dcd9e84179d3575b845c6958a166748894a0b30204469d9afb742 |