Skip to content

docs: add Japanese (i18n) builds for HTML and latexpdf#327

Merged
ttadano merged 3 commits into
2.0devfrom
docs/i18n-japanese
Jun 29, 2026
Merged

docs: add Japanese (i18n) builds for HTML and latexpdf#327
ttadano merged 3 commits into
2.0devfrom
docs/i18n-japanese

Conversation

@ttadano

@ttadano ttadano commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

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_LANGUAGE env var (default en); untranslated strings fall back to English, so the Japanese site is usable immediately and fills in as catalogs are translated.

What's included

  • conf.pylanguage from DOCS_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.
  • Makefilehtml-ja, latexpdf-ja, update-po targets.
  • requirements.txtsphinx-intl for catalog management.
  • languages.txt — per-branch source of truth (first entry = default) that CI reads.
  • _static/ — new language-switcher.{js,css}; version-switcher.js updated for the nested <version>/<lang>/ layout.
  • locale/ja/ — 24 scaffolded gettext catalogs (empty msgstr, ready to translate); one sample entry filled in (Users Guideユーザーガイド) to exercise the pipeline.
  • docs.yml — per-version language matrix → <version>/<lang>/ + per-version languages.json + landing redirect; PR validation builds every language; new Build Japanese PDF job (LuaLaTeX) uploads the PDF as an artifact. Branches without languages.txt keep the existing single-language layout (fully backward compatible).

Translator workflow

cd docs
make update-po     # refresh source/locale/ja catalogs after docs change
# …fill in msgstr "" in source/locale/ja/LC_MESSAGES/*.po…
make html-ja       # preview Japanese HTML
make latexpdf-ja   # Japanese PDF via lualatex

Verified locally (venv = pinned requirements + sphinx-intl)

  • English & Japanese HTML build clean; translated string renders only in ja, no leak into en.
  • Japanese PDF: 157 pages via LuaLaTeX, CJK glyphs render, 0 missing-glyph warnings.
  • Published layout/manifests correct; both switchers render and reflect state in a real browser (日本語 on /ja/, English on /en/).
  • docs.yml parses; the bash language-matrix logic yields ["en","ja"] and the right dirs/redirects.

Reviewer notes

  1. The CI Japanese-PDF job needs a first-run sanity check. The LaTeX config and build are verified locally, but I can't run Actions here to confirm Ubuntu's fonts-freefont-otf is picked up by luaotfload for the Latin body font. If not, the fix is a one-line font override in conf.py (point \setmainfont at Harano Aji).
  2. The PDF is uploaded as a CI artifact, not published to the Pages site — kept off the deploy path to avoid touching the working multi-version deploy. Easy to wire into the site (e.g. …/<version>/ja/ALAMODE.pdf) as a follow-up if wanted.

🤖 Generated with Claude Code

ttadano and others added 3 commits June 29, 2026 21:46
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>
@ttadano
ttadano merged commit adefea6 into 2.0dev Jun 29, 2026
3 checks passed
@ttadano
ttadano deleted the docs/i18n-japanese branch June 29, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant