@@ -149,17 +149,24 @@ def _compile_mo_catalog(locale: str) -> None:
149149 """Compile .po -> .mo when catalogs are missing or stale."""
150150 if not _locale_po_files (locale ):
151151 return
152- subprocess .run (
153- [sys .executable , str (_doc_root / "build_i18n.py" ), locale ],
154- cwd = str (_doc_root ),
155- check = True ,
156- )
152+ try :
153+ subprocess .run (
154+ [sys .executable , str (_doc_root / "build_i18n.py" ), locale ],
155+ cwd = str (_doc_root ),
156+ check = True ,
157+ )
158+ except (subprocess .CalledProcessError , OSError ) as exc :
159+ print (
160+ f"[sphinx] warning: failed to compile locale/{ locale } catalogs "
161+ f"({ exc } ); continuing with existing .mo files if any" ,
162+ flush = True ,
163+ )
157164
158165
159166if _sphinx_language and _needs_mo_compile (_sphinx_language ):
160167 _compile_mo_catalog (_sphinx_language )
161168
162- if version_match == " zh-cn" or _sphinx_language == "zh_CN" :
169+ if version_match == ' zh-cn' or _sphinx_language == "zh_CN" :
163170 tags .add ("zh_cn" )
164171
165172
@@ -205,20 +212,7 @@ def _resolve_switcher_version(app):
205212}
206213
207214
208- def _apply_switcher_theme_options (theme_options : dict , switcher_version : str ) -> None :
209- """Apply locale-specific PyData theme options from one place."""
210- switcher = theme_options .setdefault ("switcher" , {})
211- switcher .setdefault ("json_url" , json_url )
212- switcher ["version_match" ] = switcher_version
213- theme_options ["external_links" ] = [
214- _EXTERNAL_LINKS_BY_LOCALE .get (switcher_version , _DEFAULT_EXTERNAL_LINK )
215- ]
216- theme_options ["header_dropdown_text" ] = _HEADER_DROPDOWN_TEXT_BY_LOCALE .get (
217- switcher_version , "More"
218- )
219-
220-
221- if version_match != "zh-cn" :
215+ if version_match != 'zh-cn' :
222216 html_theme_options ['icon_links' ].extend ([{
223217 "name" : "Discord" ,
224218 "url" : "https://discord.gg/Xw9tszSkr5" ,
@@ -240,16 +234,27 @@ def _apply_switcher_theme_options(theme_options: dict, switcher_version: str) ->
240234 "type" : "fontawesome" ,
241235 }])
242236
243- _apply_switcher_theme_options (html_theme_options , version_match )
237+ html_theme_options ["external_links" ] = [
238+ _EXTERNAL_LINKS_BY_LOCALE .get (version_match , _DEFAULT_EXTERNAL_LINK )
239+ ]
240+ html_theme_options ["header_dropdown_text" ] = _HEADER_DROPDOWN_TEXT_BY_LOCALE .get (
241+ version_match , "More"
242+ )
244243
245244html_favicon = "_static/xinference-favicon.png"
246245
247246
248247def _apply_locale_theme_options (app , config ):
249248 switcher_version = _resolve_switcher_version (app )
250- _apply_switcher_theme_options (config .html_theme_options , switcher_version )
249+ config .html_theme_options .setdefault ("switcher" , {})["version_match" ] = switcher_version
250+ config .html_theme_options ["external_links" ] = [
251+ _EXTERNAL_LINKS_BY_LOCALE .get (switcher_version , _DEFAULT_EXTERNAL_LINK )
252+ ]
253+ config .html_theme_options ["header_dropdown_text" ] = (
254+ _HEADER_DROPDOWN_TEXT_BY_LOCALE .get (switcher_version , "More" )
255+ )
251256 if switcher_version == "zh-cn" :
252- config .tags .add ("zh_cn" )
257+ app .tags .add ("zh_cn" )
253258
254259
255260def _remove_non_zh_cn_nodes (app , doctree , docname ):
0 commit comments