Skip to content

Commit 7655783

Browse files
committed
Check locale folder exists before building
1 parent 393cbd7 commit 7655783

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

noxfile.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Location of the translation templates
1616
TRANSLATION_TEMPLATE_DIR = pathlib.Path(BUILD_DIR, "gettext")
17+
TRANSLATION_LOCALES_DIR = pathlib.Path("locales")
1718

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

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

5051

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

0 commit comments

Comments
 (0)