Skip to content

Commit 219c0fe

Browse files
kwagyemanclaude
andcommitted
docs: set up Shibuya multilingual translation scaffolding
- Set language = "en" and add the Shibuya navbar "Translations" switcher via html_context["languages"]: English, then Simplified Chinese (zh_CN / zh-Hans), then Traditional Chinese (zh_TW / zh-Hant), with the gettext + sphinx-intl + per-language build workflow documented inline. - Remove the stale locale/zh_CN translations -- they predate all the new tutorial content and would mistranslate against it. Fresh .po files get generated from the current docs at translation time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 476fac5 commit 219c0fe

170 files changed

Lines changed: 24 additions & 48602 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/conf.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,35 @@ def _render_landing_code(src):
316316
# breakdown, so use the same version identifier for both to avoid confusion.
317317
version = release = micropython_version
318318

319-
# The language for content autogenerated by Sphinx. Refer to documentation
320-
# for a list of supported languages.
321-
# language = None
319+
# The source language. Translations are built by overriding this on the
320+
# command line, e.g. ``-D language=zh_CN``.
321+
language = "en"
322322

323323
# -- Options for i18n output ----------------------------------------------
324324
locale_dirs = ["locale"]
325325
gettext_compact = False
326326

327+
# Shibuya's navbar "Translations" switcher and the <link rel="alternate"
328+
# hreflang> tags read this list. Each entry is
329+
# (display name, URL pattern with %s for the page, hreflang).
330+
# English is the source language at the site root; each translation is a
331+
# separate per-language build deployed under its own subdirectory. To
332+
# produce one:
333+
#
334+
# pip install sphinx-intl
335+
# sphinx-build -b gettext . _build/gettext # extract .pot
336+
# sphinx-intl update -p _build/gettext -l zh_CN -l zh_TW
337+
# # ...translate locale/<lang>/LC_MESSAGES/*.po...
338+
# sphinx-build -b html -D language=zh_CN . _build/html/zh_CN
339+
# sphinx-build -b html -D language=zh_TW . _build/html/zh_TW
340+
#
341+
# The zh_CN / zh_TW entries below go live once those builds are deployed.
342+
html_context["languages"] = [
343+
("English", "/%s.html", "en"),
344+
("简体中文", "/zh_CN/%s.html", "zh-Hans"),
345+
("繁體中文", "/zh_TW/%s.html", "zh-Hant"),
346+
]
347+
327348
# There are two options for replacing |today|: either, you set today to some
328349
# non-false value, then it is used:
329350
# today = ''

0 commit comments

Comments
 (0)