Add language switcher support for fa and zh-cn repositories#490
Open
mmcky wants to merge 1 commit into
Open
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
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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