Skip to content

Commit

Permalink
Check locale folder exists before building
Browse files Browse the repository at this point in the history
  • Loading branch information
flpm committed Jun 16, 2024
1 parent 393cbd7 commit 7655783
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# Location of the translation templates
TRANSLATION_TEMPLATE_DIR = pathlib.Path(BUILD_DIR, "gettext")
TRANSLATION_LOCALES_DIR = pathlib.Path("locales")

# Sphinx build commands
SPHINX_BUILD = "sphinx-build"
Expand Down Expand Up @@ -44,8 +45,8 @@
# List of languages for which locales will be generated in (/locales/<lang>)
LANGUAGES = ["es"]

# List of languages that should be built when releasing the guide
RELEASE_LANGUAGES = ['es']
# List of languages that should be built when releasing the guide (docs or docs-test sessions)
RELEASE_LANGUAGES = []


@nox.session
Expand Down Expand Up @@ -194,8 +195,10 @@ def build_translations(session):
release_build = True
# if running from the docs or docs-test sessions, build only release languages
BUILD_LANGUAGES = RELEASE_LANGUAGES if release_build else LANGUAGES
session.log(f"Existing translations: {LANGUAGES}")
session.log(f"Release Languages: {RELEASE_LANGUAGES}")
# only build languages that have a locale folder
BUILD_LANGUAGES = [lang for lang in BUILD_LANGUAGES if (TRANSLATION_LOCALES_DIR / lang).exists()]
session.log(f"Declared languages: {LANGUAGES}")
session.log(f"Release languages: {RELEASE_LANGUAGES}")
session.log(f"Building languages{' for release' if release_build else ''}: {BUILD_LANGUAGES}")
if not BUILD_LANGUAGES:
session.warn("No translations to build")
Expand Down

0 comments on commit 7655783

Please sign in to comment.