@@ -145,18 +145,49 @@ def clean_dir(session):
145145@nox .session (name = "update-translations" )
146146def update_translations (session ):
147147 """
148- Update the translation files (./locales/*/.po) for all languages translations .
148+ Update the translation files (./locales/*/.po) for languages in RELEASE_LANGUAGES .
149149
150- Note: this step is important because it makes sure that the translation files are
151- up to date with the latest changes in the guide.
150+ Note: this step is called in the CI to keep release translations up to date with
151+ the latest changes in the guide.
152152 """
153- session .install ("-e" , "." )
154- session .install ("sphinx-intl" )
155- session .log ("Updating templates (.pot)" )
156- session .run (SPHINX_BUILD , * TRANSLATION_TEMPLATE_PARAMETERS , SOURCE_DIR , TRANSLATION_TEMPLATE_DIR , * session .posargs )
157- for lang in LANGUAGES :
158- session .log (f"Updating .po files for [{ lang } ] translation" )
159- session .run ("sphinx-intl" , "update" , "-p" , TRANSLATION_TEMPLATE_DIR , "-l" , lang )
153+ if RELEASE_LANGUAGES :
154+ session .install ("-e" , "." )
155+ session .install ("sphinx-intl" )
156+ session .log ("Updating templates (.pot)" )
157+ session .run (SPHINX_BUILD , * TRANSLATION_TEMPLATE_PARAMETERS , SOURCE_DIR , TRANSLATION_TEMPLATE_DIR , * session .posargs )
158+ for lang in RELEASE_LANGUAGES :
159+ session .log (f"Updating .po files for [{ lang } ] translation" )
160+ session .run ("sphinx-intl" , "update" , "-p" , TRANSLATION_TEMPLATE_DIR , "-l" , lang )
161+ else :
162+ session .warn ("No release languages defined in RELEASE_LANGUAGES" )
163+
164+
165+ @nox .session (name = "update-language" )
166+ def update_language (session ):
167+ """
168+ Update the translation files (./locales/*/.po) for a specific language translation.
169+
170+ Note: this step is used by language coordinators to keep their translation files up to date
171+ with the latest changes in the guide, before the translation is released.
172+ """
173+ if session .posargs and (lang := session .posargs .pop (0 )):
174+ if lang in LANGUAGES :
175+ session .install ("-e" , "." )
176+ session .install ("sphinx-intl" )
177+ session .log ("Updating templates (.pot)" )
178+ session .run (SPHINX_BUILD , * TRANSLATION_TEMPLATE_PARAMETERS , SOURCE_DIR , TRANSLATION_TEMPLATE_DIR , * session .posargs )
179+ session .log (f"Updating .po files for [{ lang } ] translation" )
180+ session .run ("sphinx-intl" , "update" , "-p" , TRANSLATION_TEMPLATE_DIR , "-l" , lang )
181+ else :
182+ f"[{ lang } ] locale is not available. Try using:\n \n "
183+ "nox -s docs-live-lang -- LANG\n \n "
184+ f"where LANG is one of: { LANGUAGES } "
185+ else :
186+ session .error (
187+ "Please provide a language using:\n \n "
188+ "nox -s update-language -- LANG\n \n "
189+ f" where LANG is one of: { LANGUAGES } "
190+ )
160191
161192
162193@nox .session (name = "build-languages" )
0 commit comments