Skip to content
Open
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
16 changes: 16 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def update_release_languages(session):
if RELEASE_LANGUAGES:
session.install("-e", ".")
session.install("sphinx-intl")
_clean_translation_templates(session)
session.log("Updating templates (.pot)")
session.run(
SPHINX_BUILD,
Expand Down Expand Up @@ -298,6 +299,7 @@ def update_language(session):
if lang in LANGUAGES:
session.install("-e", ".")
session.install("sphinx-intl")
_clean_translation_templates(session)
session.log("Updating templates (.pot)")
session.run(
SPHINX_BUILD,
Expand Down Expand Up @@ -427,6 +429,20 @@ def build_all_languages_test(session):
session.notify("build-all-languages", [*TEST_PARAMETERS])


def _clean_translation_templates(session) -> None:
"""
Remove the gettext output directory before regenerating the templates (.pot).

The gettext build is incremental and never deletes a .pot whose source page is
gone, while `sphinx-intl update` creates a .po for every .pot it finds. Without
this, a page that briefly existed in the source tree leaves an orphan .pot
behind, and every later update spawns a matching .po in each locale.
"""
if TRANSLATION_TEMPLATE_DIR.exists():
session.log(f"Cleaning out {TRANSLATION_TEMPLATE_DIR}")
shutil.rmtree(TRANSLATION_TEMPLATE_DIR)


def _sphinx_env(session) -> str:
"""
Get the sphinx env, from the first positional argument if present or from the
Expand Down
Loading