diff --git a/docs/markdown/snippets/xgettext-include-private-dependencies.md b/docs/markdown/snippets/xgettext-include-private-dependencies.md new file mode 100644 index 000000000000..81f97c654689 --- /dev/null +++ b/docs/markdown/snippets/xgettext-include-private-dependencies.md @@ -0,0 +1,24 @@ +## i18n.xgettext recursive option now includes "private" dependencies + +Suppose we have: + +``` +libA.dll -> libB.dll -> libC.dll +``` + +Here, `libA` links with `libB`, and `libB` links with `libC`, but `libA` does +not link with `libC` directly. So, `libC` is a "private" dependency of `libB`. +If we collect strings to translate using: + +``` +i18n.xgettext(libC) +i18n.xgettext(libB) +pot_file = i18n.xgettext(libA, recursive: true) +``` + +Previously, strings from `libC` would not be included in `pot_file`, since +`libC` is not a direct link dependency of `libA`. This has been fixed: when +the `recursive: true` option is used, `xgettext` now recursively includes +translations from all dependencies, including those of dependencies. This is +more logical, as even if `libA` does not directly link with `libC`, it may +still need translated strings from `libC`. diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 2d8d04d3ec30..b2e78251a6c6 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -209,9 +209,11 @@ def _get_depends(self, sources: T.Iterable[SourcesType]) -> T.Set[build.CustomTa depends = set() for source in sources: if isinstance(source, build.BuildTarget): - for source_id in self._get_source_id(source.get_dependencies()): + dependencies = source.get_dependencies() + for source_id in self._get_source_id(dependencies): if source_id in self.pot_files: depends.add(self.pot_files[source_id]) + depends.update(self._get_depends(dependencies)) elif isinstance(source, build.CustomTarget): # Dependency on another extracted pot file source_id = source.get_id()