summaryrefslogtreecommitdiff
path: root/docs/markdown/i18n-module.md
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2024-11-07 10:58:14 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2025-04-09 18:41:00 +0300
commit1afdac1bc4cbf9816e7109bbedef2825c4fe1155 (patch)
tree1a378a4ccd00e0e49c831f32e324fa8e0db7f6ab /docs/markdown/i18n-module.md
parent0c9420205cc132743e5b3788b3a6a87502e79415 (diff)
downloadmeson-1afdac1bc4cbf9816e7109bbedef2825c4fe1155.tar.gz
New xgettext method for i18n module
This method call xgettext to extract translatable string from source files into a .pot translation template. It differs from a plain CustomTarget in three ways: - It accepts build targets as sources, and automatically resolves source files from those build targets; - It detects command lines that are too long, and writes, at config time, the list of source files into a text file to be consumed by the xgettext command; - It detects dependencies between pot extraction targets, based on the dependencies between source targets.
Diffstat (limited to 'docs/markdown/i18n-module.md')
-rw-r--r--docs/markdown/i18n-module.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/markdown/i18n-module.md b/docs/markdown/i18n-module.md
index a939a3473..da6fce74e 100644
--- a/docs/markdown/i18n-module.md
+++ b/docs/markdown/i18n-module.md
@@ -74,3 +74,50 @@ for normal keywords. In addition it accepts these keywords:
* `mo_targets` *required*: mo file generation targets as returned by `i18n.gettext()`.
*Added 0.62.0*
+
+
+### i18n.xgettext()
+
+``` meson
+i18n.xgettext(name, sources..., args: [...], recursive: false)
+```
+
+Invokes the `xgettext` program on given sources, to generate a `.pot` file.
+This function is to be used when the `gettext` function workflow it not suitable
+for your project. For example, it can be used to produce separate `.pot` files
+for each executable.
+
+Positional arguments are the following:
+
+* name `str`: the name of the resulting pot file.
+* sources `list[str|File|build_tgt|custom_tgt]`:
+ source files or targets. May be a list of `string`, `File`, [[@build_tgt]],
+ or [[@custom_tgt]] returned from other calls to this function.
+
+Keyword arguments are the following:
+
+- recursive `bool`:
+ if `true`, will merge the resulting pot file with extracted pot files
+ related to dependencies of the given source targets. For instance,
+ if you build an executable, then you may want to merge the executable
+ translations with the translations from the dependent libraries.
+- install `bool`: if `true`, will add the resulting pot file to install targets.
+- install_tag `str`: install tag to use for the install target.
+- install_dir `str`: directory where to install the resulting pot file.
+
+The `i18n.xgettext()` function returns a [[@custom_tgt]].
+
+Usually, you want to pass one build target as sources, and the list of header files
+for that target. If the number of source files would result in a command line that
+is too long, the list of source files is written to a file at config time, to be
+used as input for the `xgettext` program.
+
+The `recursive: true` argument is to be given to targets that will actually read
+the resulting `.mo` file. Each time you call the `i18n.xgettext()` function,
+it maps the source targets to the resulting pot file. When `recursive: true` is
+given, all generated pot files from dependencies of the source targets are
+included to generate the final pot file. Therefore, adding a dependency to
+source target will automatically add the translations of that dependency to the
+needed translations for that source target.
+
+*Added 1.8.0*