Skip to content

Commit 5bf51c3

Browse files
committed
Configure docs as three Read the Docs translation projects
Read the Docs's prescribed multi-language layout is one project per language linked under a main project's Translations tab. Add the two missing translation configs (.readthedocs.zh-TW.yaml, .readthedocs.zh-CN.yaml) so each Sphinx source tree builds as its own RTD project. Set language explicitly on every conf.py and pull html_baseurl from READTHEDOCS_CANONICAL_URL so canonical link tags match the per-language URL RTD serves. Replace the relative ../html-*/index.html switcher links with absolute https://fileautomation.readthedocs.io/<lang>/latest/ URLs so cross-language navigation works on the public site (the relative form 404s because only the English source was built on RTD), and add a brief note pointing to RTD's built-in language flyout.
1 parent ecad849 commit 5bf51c3

9 files changed

Lines changed: 92 additions & 6 deletions

File tree

.readthedocs.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# .readthedocs.yaml
2-
# Read the Docs configuration file
3-
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
2+
# Read the Docs configuration file for the English ("fileautomation") project.
3+
# Sibling files .readthedocs.zh-TW.yaml and .readthedocs.zh-CN.yaml configure
4+
# the two translation projects. Wire each translation project to its own YAML
5+
# in the RTD project admin (Settings → Default settings → Path), and link the
6+
# three projects via the main project's Translations tab.
7+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
8+
# https://docs.readthedocs.io/en/stable/localization.html
49

510
# Required
611
version: 2
@@ -11,7 +16,7 @@ build:
1116
tools:
1217
python: "3.11"
1318

14-
# Build documentation in the "docs/" directory with Sphinx
19+
# Build the English documentation in docs/source with Sphinx.
1520
sphinx:
1621
configuration: docs/source/conf.py
1722

.readthedocs.zh-CN.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# .readthedocs.zh-CN.yaml
2+
# Read the Docs configuration file for the Simplified Chinese
3+
# ("fileautomation-zh-cn") translation project. Linked from the main
4+
# "fileautomation" project's Translations tab so RTD serves it at
5+
# https://fileautomation.readthedocs.io/zh_CN/<version>/.
6+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
7+
# https://docs.readthedocs.io/en/stable/localization.html
8+
9+
version: 2
10+
11+
build:
12+
os: ubuntu-22.04
13+
tools:
14+
python: "3.11"
15+
16+
# Build the Simplified Chinese documentation in docs/source.zh-CN with Sphinx.
17+
sphinx:
18+
configuration: docs/source.zh-CN/conf.py
19+
20+
python:
21+
install:
22+
- requirements: docs/requirements.txt

.readthedocs.zh-TW.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# .readthedocs.zh-TW.yaml
2+
# Read the Docs configuration file for the Traditional Chinese
3+
# ("fileautomation-zh-tw") translation project. Linked from the main
4+
# "fileautomation" project's Translations tab so RTD serves it at
5+
# https://fileautomation.readthedocs.io/zh_TW/<version>/.
6+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
7+
# https://docs.readthedocs.io/en/stable/localization.html
8+
9+
version: 2
10+
11+
build:
12+
os: ubuntu-22.04
13+
tools:
14+
python: "3.11"
15+
16+
# Build the Traditional Chinese documentation in docs/source.zh-TW with Sphinx.
17+
sphinx:
18+
configuration: docs/source.zh-TW/conf.py
19+
20+
python:
21+
install:
22+
- requirements: docs/requirements.txt

docs/source.zh-CN/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
language = "zh_CN"
1717
html_title = "automation_file 文档(简体中文)"
1818

19+
# Read the Docs sets READTHEDOCS_CANONICAL_URL to the per-translation canonical
20+
# URL (e.g. https://fileautomation.readthedocs.io/zh_CN/latest/). Use it as the
21+
# base URL so canonical <link rel="canonical"> tags and the translations flyout
22+
# resolve correctly. Empty string off-RTD.
23+
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
24+
1925
extensions = [
2026
"sphinx.ext.autodoc",
2127
"sphinx.ext.napoleon",

docs/source.zh-CN/index.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ Dropbox、OneDrive、Box、SFTP、FTP / FTPS、WebDAV、SMB、fsspec)、
1717
* **Issue / 未来规划**:https://github.com/Integration-Automation/FileAutomation/issues
1818
* **许可**:MIT
1919

20-
语言:`English <../html/index.html>`_ | `繁體中文 <../html-zh-TW/index.html>`_ | **简体中文**
20+
语言:`English <https://fileautomation.readthedocs.io/en/latest/>`_ | `繁體中文 <https://fileautomation.readthedocs.io/zh_TW/latest/>`_ | **简体中文**
21+
22+
.. note::
23+
24+
每个语言都是独立的 Read the Docs 项目,并挂在主项目
25+
``fileautomation`` 下作为翻译。RTD 也会在每页右下角的版本菜单中
26+
自动提供语言切换器。
2127

2228
.. contents:: 本页目录
2329
:local:

docs/source.zh-TW/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
language = "zh_TW"
1717
html_title = "automation_file 文件(繁體中文)"
1818

19+
# Read the Docs sets READTHEDOCS_CANONICAL_URL to the per-translation canonical
20+
# URL (e.g. https://fileautomation.readthedocs.io/zh_TW/latest/). Use it as the
21+
# base URL so canonical <link rel="canonical"> tags and the translations flyout
22+
# resolve correctly. Empty string off-RTD.
23+
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
24+
1925
extensions = [
2026
"sphinx.ext.autodoc",
2127
"sphinx.ext.napoleon",

docs/source.zh-TW/index.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ Dropbox、OneDrive、Box、SFTP、FTP / FTPS、WebDAV、SMB、fsspec)、
1717
* **Issue / 未來規劃**:https://github.com/Integration-Automation/FileAutomation/issues
1818
* **授權**:MIT
1919

20-
語言:`English <../html/index.html>`_ | **繁體中文** | `简体中文 <../html-zh-CN/index.html>`_
20+
語言:`English <https://fileautomation.readthedocs.io/en/latest/>`_ | **繁體中文** | `简体中文 <https://fileautomation.readthedocs.io/zh_CN/latest/>`_
21+
22+
.. note::
23+
24+
每個語言都是獨立的 Read the Docs 專案,並掛在主專案
25+
``fileautomation`` 下作為翻譯。RTD 也會在每頁右下角的版本選單中
26+
自動提供語言切換器。
2127

2228
.. contents:: 本頁目錄
2329
:local:

docs/source/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
author = "JE-Chen"
1414
copyright = "2026, JE-Chen" # pylint: disable=redefined-builtin # Sphinx requires this name
1515
release = "0.0.32"
16+
language = "en"
17+
18+
# Read the Docs sets READTHEDOCS_CANONICAL_URL to the per-translation canonical
19+
# URL (e.g. https://fileautomation.readthedocs.io/en/latest/). Use it as the
20+
# base URL so canonical <link rel="canonical"> tags and the translations flyout
21+
# resolve correctly. Empty string off-RTD.
22+
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
1623

1724
extensions = [
1825
"sphinx.ext.autodoc",

docs/source/index.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ and exposed from a single ``automation_file`` facade.
1818
* **Issues / RoadMap** — https://github.com/Integration-Automation/FileAutomation/issues
1919
* **License** — MIT
2020

21-
Languages: **English** | `繁體中文 <../html-zh-TW/index.html>`_ | `简体中文 <../html-zh-CN/index.html>`_
21+
Languages: **English** | `繁體中文 <https://fileautomation.readthedocs.io/zh_TW/latest/>`_ | `简体中文 <https://fileautomation.readthedocs.io/zh_CN/latest/>`_
22+
23+
.. note::
24+
25+
Each language is served as its own Read the Docs project, linked as a
26+
translation of ``fileautomation``. RTD also exposes a built-in language
27+
selector inside the version flyout in the bottom-right of every page.
2228

2329
.. contents:: On this page
2430
:local:

0 commit comments

Comments
 (0)