Add language switcher support for fa and zh-cn repositories#490
Conversation
Add `languages` and `current_language` to `html_theme_options` to enable the language switcher (globe icon) and SEO hreflang tags provided by quantecon-book-theme. Main already ships the 0.21.0 theme, so no environment change is needed here. Languages: - English (en) — https://python-programming.quantecon.org - فارسی (fa) — https://quantecon.github.io/lecture-python-programming.fa - 中文 (zh-cn) — https://quantecon.github.io/lecture-python-programming.zh-cn Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4c4ed45 to
4d35290
Compare
There was a problem hiding this comment.
Pull request overview
Adds multi-language switcher configuration to the Jupyter Book theme settings so the site can link between the English, Farsi, and Simplified Chinese builds (and emit corresponding hreflang alternates).
Changes:
- Adds
languagesentries (en, fa, zh-cn) undersphinx.config.html_theme_options. - Sets
current_language: ento mark the English build as active.
|
Heads-up: French now exists and this PR does not include it.
Not asking for a rewrite here — flagging it so the gap is a decision rather than an oversight. Two things worth knowing if French is added:
Tracked in QuantEcon/project-translation#3 (rollout) — happy to add French here once the site is published, or to leave it for a follow-up. |
Changes
Add the language switcher configuration to
html_theme_optionsinlectures/_config.yml:https://python-programming.quantecon.orghttps://quantecon.github.io/lecture-python-programming.fahttps://quantecon.github.io/lecture-python-programming.zh-cncurrent_language: enThis enables the language switcher globe icon in the bottom toolbar and injects SEO
hreflangtags for all configured languages.No
environment.ymlchange is needed:mainalready shipsquantecon-book-theme==0.21.0(bumped in #558), which provides the switcher. This branch was rebased onto currentmainso it is now a single-file_config.ymlchange.Verified against
quantecon-book-theme==0.21.0with a local build: the switcher renders all three languages (English active) and thehreflangalternates — includingx-default→ en — inject correctly into<head>.Ref: https://github.com/QuantEcon/quantecon-book-theme/releases/tag/v0.20.0