Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update-po Makefile target #529

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Create a Python `virtual environment <https://docs.python.org/3/tutorial/venv.ht

Then install the dependencies with **pip**::

pip install -r requirements.txt sphinx-intl
pip install -r requirements.txt

Build the Documentation
-----------------------
Expand All @@ -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
--------
Expand Down
14 changes: 13 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ furo
matplotlib
sphinxext-opengraph
sphinx-copybutton
sphinx-intl
Loading