Skip to content

Commit f595a47

Browse files
committed
Add language support and configuration in documentation
- Introduced dynamic language selection in `conf.py` based on environment variable. - Set up separate README files for English and Chinese builds. - Updated `html_context` to include language pairs and current language settings for better localization support.
1 parent 9f9f39f commit f595a47

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

docs/source/conf.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@
2424
# The full version, including alpha/beta/rc tags
2525
release = '1.0.1'
2626

27+
# The language for content autogenerated by Sphinx
28+
language = os.environ.get('SPHINX_LANGUAGE', 'en') # Default to English if not specified
29+
30+
# Choose the appropriate README file based on language
31+
if language == 'zh_CN':
32+
# Use Chinese README for Chinese builds
33+
master_doc = 'README_CN'
34+
else:
35+
# Use English README for all other languages (including default English)
36+
master_doc = 'README'
37+
38+
# List of supported languages
39+
languages = ['en', 'zh_CN']
40+
41+
# Language to use in text generated by Sphinx
42+
language_pairs = {
43+
'en': 'English',
44+
'zh_CN': '简体中文',
45+
}
2746

2847
# -- General configuration ---------------------------------------------------
2948

@@ -60,12 +79,11 @@
6079

6180
# -- Options for ReadTheDocs ------------------------------------------------
6281

63-
# ReadTheDocs specific settings
82+
# Optional: Language selector HTML context (if you want to add a language switcher)
6483
html_context = {
6584
'display_language_tabs': True,
6685
'current_language': 'en',
67-
'languages': {
68-
'en': 'English',
69-
'zh_CN': '中文',
70-
},
71-
}
86+
'languages': languages,
87+
'language_pairs': language_pairs,
88+
'current_language': language,
89+
}

0 commit comments

Comments
 (0)