Feature Request: Support Internationalization with Gettext
Hello @getzola community,
I am the author of the @localizethedocs organization, which specializes in establishing localization infrastructure for open-source documentation. We have already developed scalable workflows for numerous Sphinx and mdBook projects:
- Sphinx utilizes its built-in
gettextbuilder along with relevant i18n options. - mdBook utilizes the renderer and preprocessor provided by
mdbook-i18n-helpers.
If Zola introduces Gettext-based internationalization (i18n), I will be able to expand our support to include documentation built with Zola. Below are the details of this feature request.
Feature Request
Implement a Gettext-based workflow that allows users to extract translatable source strings from Zola-based documentation into .pot files. During the build process, the system should be able to reference translated .po files to generate localized versions of the documentation.
I propose adding the following arguments to the zola build command to facilitate automated localization:
--potor--gettext: Generates.potfiles from the source.--language <lang>: Specifies the target language for the build.--locale-dir <dir>: Defines the directory containing the locale-specific data.
with the expected workflow:
# 1. Generate .pot files to the './out/pot' directory.
zola build --pot --output-dir ./out/pot
# 2. Convert .pot to the language-specific .po files inside 'locale' directory.
#
# ```
# out/
# pot/
# guide.pot
# index.pot
# zola.pot
# locale/
# zh_CN/
# LC_MESSAGES/
# guide.po
# index.po
# zola.po
# zh_TW/
# LC_MESSAGES/
# guide.po
# index.po
# zola.po
# content/
# guide.md
# _index.md
# config.toml
# ```
# 3. Build the documentation with the .po files in './locale/zh_TW' directory.
zola build --language zh_TW --locale-dir ./locale --output-dir ./out/html/The proposed workflow aligns with Sphinx's Internationalization with Gettext feature, as illustrated in its official documentation:
This implementation allows core maintainers to focus exclusively on English source content. Meanwhile, the localization process can be decoupled and managed in independent downstream repositories (just like what @localizethedocs does), preventing the upstream project history from being overwhelmed by translation-related commits.
Previous Discussions
I noticed that the Zola community has previously discussed implementing internationalization features:
- https://github.com/getzola/zola/issues/110
- https://github.com/getzola/zola/issues/1058
- https://zola.discourse.group/t/rfc-internationalization-system-rework/546
At the time, community proposals suggested using either Fluent or Gettext as the underlying engine for Zola's internationalization. However, it seems that little progress has been made since then.
If I were to vote today on whether to use Fluent or Gettext for internationalization, I would choose Gettext without hesitation. It's because Gettext comes with a mature and stable suite of utilities (xgettext, msgmerge, msgcat, etc.) that allow users to combine scripts with CI/CD to build workflows that automatically update translation progress.
I hope this feature request offers a different perspective on implementing internationalization in Zola.
Source: getzola/zola