From b4a998a14316ef37359cf3fcb5c67f0ab795def7 Mon Sep 17 00:00:00 2001 From: zihang Date: Wed, 15 Jan 2025 15:52:45 +0800 Subject: [PATCH 1/2] doc(i18n): translate some extra stuff --- next/conf.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/next/conf.py b/next/conf.py index fcfaa404..b3b9d2a6 100644 --- a/next/conf.py +++ b/next/conf.py @@ -6,11 +6,19 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'MoonBit Document' -copyright = '2025, International Digital Economy Academy' +project = 'MoonBit' author = 'International Digital Economy Academy' +copyright = '%Y, {author}'.format(author=author) release = 'v0.1.20250113' +# I18N based on Readthedocs Environment +# https://docs.readthedocs.io/en/stable/reference/environment-variables.html +import os +if os.getenv('READTHEDOCS_LANGUAGE') == 'zh-cn': + project = 'MoonBit 月兔' + author = '粤港澳大湾区数字经济院' + copyright = '%Y, {author}'.format(author=author) + # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration @@ -39,7 +47,7 @@ "use_edit_page_button": True, "use_issues_button": True, "logo": { - "text":"MoonBit Documentation", + "text":"MoonBit 月兔", } } html_logo = "_static/logo.png" From f858ff32b9b2c1d89c5fa69998f9a17db3315780 Mon Sep 17 00:00:00 2001 From: zihang Date: Wed, 15 Jan 2025 16:02:15 +0800 Subject: [PATCH 2/2] chore(next): use custom i18n configuration --- document.code-workspace | 4 ++-- next/README.md | 2 +- next/conf.py | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/document.code-workspace b/document.code-workspace index e01256b9..3b13ff77 100644 --- a/document.code-workspace +++ b/document.code-workspace @@ -26,7 +26,7 @@ "options": { "env": { "SPHINXBUILD": "sphinx-autobuild", - "SPHINXOPTS": "-D language='${input:language}'" + "LANGUAGE": "${input:language}" }, "cwd": "${workspaceFolder:document}" }, @@ -41,7 +41,7 @@ ], "options": { "env": { - "SPHINXOPTS": "-D language='${input:language}'" + "LANGUAGE": "${input:language}" }, "cwd": "${workspaceFolder:document}" }, diff --git a/next/README.md b/next/README.md index 0cec7fc6..1384f86d 100644 --- a/next/README.md +++ b/next/README.md @@ -40,7 +40,7 @@ python3 -m http.server -d _build/html For Chinese version: ```bash -make -e SPHINXOPTS="-D language='zh_CN'" html +LANGUAGE="zh_CN" make html python3 -m http.server -d _build/html ``` diff --git a/next/conf.py b/next/conf.py index b3b9d2a6..376b6c2f 100644 --- a/next/conf.py +++ b/next/conf.py @@ -14,10 +14,12 @@ # I18N based on Readthedocs Environment # https://docs.readthedocs.io/en/stable/reference/environment-variables.html import os -if os.getenv('READTHEDOCS_LANGUAGE') == 'zh-cn': +if (os.getenv('READTHEDOCS_LANGUAGE') == 'zh-cn' or + os.getenv('LANGUAGE') == 'zh_CN'): # For local build project = 'MoonBit 月兔' author = '粤港澳大湾区数字经济院' copyright = '%Y, {author}'.format(author=author) + language = 'zh_CN' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration