From f9ba944a332652c8fcff95df90f8d37f3418b975 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 26 Sep 2024 20:10:26 -0300 Subject: [PATCH 1/3] Add Makefile target update-po --- docs/Makefile | 14 +++++++++++++- requirements.txt | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index af07c3ac..c8989415 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -16,7 +16,19 @@ endif help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +update-po: + @$(SPHINXBUILD) -M gettext "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @sphinx-intl update -p "$(BUILDDIR)/gettext" -d $(SOURCEDIR)/../po + @potfiles=$$(find $(BUILDDIR)/gettext -name '*.pot' | sed 's|.*/||'); \ + pofiles=$$(find ../po -name '*.po' | sort -u); \ + for po in $$pofiles; do \ + name=$$(echo $$po | sed 's|.*/LC_MESSAGES/||'); \ + if ! [[ $$potfiles =~ $${name}t ]]; then \ + rm $$po; \ + fi; \ + done + +.PHONY: help Makefile update-po # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). diff --git a/requirements.txt b/requirements.txt index adf86252..16f174fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ furo matplotlib sphinxext-opengraph sphinx-copybutton +sphinx-intl From ccd58194f3f8dffbf889ed4e479fb925931be2cb Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 26 Sep 2024 20:10:58 -0300 Subject: [PATCH 2/3] Update translation-related commands in README --- README.rst | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 0ebd5438..12300f3c 100644 --- a/README.rst +++ b/README.rst @@ -45,23 +45,18 @@ By default, the document being built is in English. If you want to build documents in other languages, such as Chinese, you can use the following command:: - sphinx-build -b html -D language=zh_CN docs docs/_build/html/zh_CN - -Then you will see the Chinese documentation in the directory -``docs/_build/html/zh_CN`` . + make -C docs html SPHINXOPTS='-D language=zh_CN' Translate the Documentation --------------------------- You can open a pull request adding a new language. -Maintainers can generate the ``.pot`` files by running:: - - make -C docs gettext - -To update ``.po`` files run:: +Maintainers can generate the template files (``.pot``), update the translation +files (``.po``) and remove obsolete translation files (i.e. a matching ``.pot`` +file no longer exists) by running:: - sphinx-intl update -p docs/_build/gettext -d po + make -C docs update-po Audience -------- From 35cf213ae6e1b1bbd3515f746bf08162e07b05d1 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 26 Sep 2024 22:49:15 -0300 Subject: [PATCH 3/3] sphinx-intl added to requirements.txt --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 12300f3c..c1db3400 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,7 @@ Create a Python `virtual environment