docs: add Japanese (i18n) builds for HTML and latexpdf#327
Merged
Conversation
Adds an English/Japanese multi-language option to the Sphinx docs,
driven by gettext catalogs and selected at build time via the
DOCS_LANGUAGE environment variable.
- conf.py: set `language` from DOCS_LANGUAGE (default en); add
locale_dirs + gettext_compact; for Japanese switch to LuaLaTeX with
the LuaTeX-ja document classes (ltjsbook/ltjsarticle) and drop
polyglossia/babel, which otherwise abort on the Latin body font.
- Makefile: add html-ja, latexpdf-ja and update-po targets.
- requirements.txt: add sphinx-intl for catalog management.
- languages.txt: per-branch source of truth (first entry = default)
that CI reads to decide which languages to publish.
- _static: new language-switcher.{js,css}; version-switcher.js updated
for the nested <version>/<lang>/ published layout.
- locale/ja: scaffolded gettext catalogs (empty msgstr, ready to
translate); one sample entry filled in to exercise the pipeline.
- docs.yml: build a per-version language matrix into <version>/<lang>/
with a per-version languages.json + landing redirect, validate every
language on pull requests, and add a job that builds the Japanese PDF
with LuaLaTeX and uploads it as an artifact. Branches without
languages.txt keep the existing single-language layout.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Build Japanese PDF job failed with "Can't exec xindy". For non-pdflatex engines Sphinx defaults the LaTeX index builder to xindy, which is a separate system package not in the job's TeX Live install (it happened to be present in a full local TeX Live, so it passed locally). The index here is Latin (tag/function names), so set latex_use_xindy = False to use makeindex instead -- it ships with TeX Live and is already what the English pdflatex build uses, keeping the CI install self-contained. Verified end to end: PDF builds via makeindex with zero xindy references. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fill in all 24 ja gettext catalogs (1728 messages) with Japanese translations of the English source. Technical terms are given in Japanese with the English in parentheses on first use (e.g. 非調和力定数 (anharmonic force constants)); code blocks, reST roles, inline literals, math, tags/keywords, file and program names are kept verbatim. Also fix five entries where a CJK character sat directly against inline reST markup (e.g. 。:doc:, ``...``(, :red:`...`(), which docutils does not recognize as a markup boundary. Inserted the escaped-space idiom (\ ) at those boundaries so the roles/links/emphasis parse correctly and render with no visible space. Verified: all catalogs parse (msgfmt/babel), entry counts unchanged; Japanese HTML builds with no translation warnings (:doc: links and emphasis render); Japanese PDF builds via lualatex+makeindex (159 pages, no missing glyphs). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Adds an English/Japanese multi-language option to the Sphinx docs for both HTML and latexpdf, built on Sphinx's native gettext i18n. The build language is selected via the
DOCS_LANGUAGEenv var (defaulten); untranslated strings fall back to English, so the Japanese site is usable immediately and fills in as catalogs are translated.What's included
conf.py—languagefromDOCS_LANGUAGE;locale_dirs+gettext_compact. For Japanese:latex_engine='lualatex'with the LuaTeX-ja classes (ltjsbook/ltjsarticle) and polyglossia/babel disabled (their\setmainlanguage{japanese}otherwise aborts against the Latin body font). Registers the language-switcher assets.Makefile—html-ja,latexpdf-ja,update-potargets.requirements.txt—sphinx-intlfor catalog management.languages.txt— per-branch source of truth (first entry = default) that CI reads._static/— newlanguage-switcher.{js,css};version-switcher.jsupdated for the nested<version>/<lang>/layout.locale/ja/— 24 scaffolded gettext catalogs (emptymsgstr, ready to translate); one sample entry filled in (Users Guide→ユーザーガイド) to exercise the pipeline.docs.yml— per-version language matrix →<version>/<lang>/+ per-versionlanguages.json+ landing redirect; PR validation builds every language; new Build Japanese PDF job (LuaLaTeX) uploads the PDF as an artifact. Branches withoutlanguages.txtkeep the existing single-language layout (fully backward compatible).Translator workflow
Verified locally (venv = pinned requirements + sphinx-intl)
ja, no leak intoen./ja/, English on/en/).docs.ymlparses; the bash language-matrix logic yields["en","ja"]and the right dirs/redirects.Reviewer notes
fonts-freefont-otfis picked up by luaotfload for the Latin body font. If not, the fix is a one-line font override inconf.py(point\setmainfontat Harano Aji).…/<version>/ja/ALAMODE.pdf) as a follow-up if wanted.🤖 Generated with Claude Code