diff --git a/TESTING_SPHINX_EXERCISE_I18N.md b/TESTING_SPHINX_EXERCISE_I18N.md new file mode 100644 index 00000000..bd050523 --- /dev/null +++ b/TESTING_SPHINX_EXERCISE_I18N.md @@ -0,0 +1,76 @@ +# Testing sphinx-exercise Internationalization Support + +This branch (`tst-sphinx-exercise`) is configured to test the internationalization (i18n) support for sphinx-exercise from PR #75. + +## Changes Made + +The environment files have been updated to install sphinx-exercise directly from the TeachBooks fork that includes i18n support: + +- **environment.yml**: Updated to use `git+https://github.com/TeachBooks/sphinx-exercise.git@main` +- **environment-cn.yml**: Updated to use `git+https://github.com/TeachBooks/sphinx-exercise.git@main` + +## Setup Instructions + +1. **Recreate the conda environment** to install the development version: + ```bash + conda env remove -n quantecon + conda env create -f environment.yml + # Or for China mirror: + # conda env create -f environment-cn.yml + ``` + +2. **Activate the environment**: + ```bash + conda activate quantecon + ``` + +3. **Verify the installation**: + ```bash + python -c "import sphinx_exercise; print(sphinx_exercise.__version__)" + ``` + +## Testing i18n Support + +The configuration in `lectures/_config.yml` already includes: +- `language: zh_CN` - This sets the Sphinx language to Chinese +- `sphinx_exercise` extension is loaded + +With the PR #75 changes, exercise and solution labels should now automatically translate to Chinese when building the documentation. + +### Build the documentation + +```bash +cd lectures +jupyter-book build . +``` + +### What to Check + +Look for translated labels in the built HTML: +- **Exercise** should appear as the Chinese equivalent (练习) +- **Solution to** should appear as the Chinese equivalent (解答) + +You can inspect the HTML output in `lectures/_build/html/` or check specific lecture files that contain exercises. + +## PR Reference + +- **Pull Request**: https://github.com/executablebooks/sphinx-exercise/pull/75 +- **Issue**: https://github.com/executablebooks/sphinx-exercise/issues/73 +- **Branch**: TeachBooks:main + +## Features Added by PR #75 + +1. Translation infrastructure using Sphinx's i18n system +2. Support for multiple languages including Chinese (zh_CN) +3. Automatic translation of "Exercise" and "Solution to" labels +4. Translation files in `.po` format for various languages + +## Reverting Changes + +To revert back to the stable version: + +```bash +git checkout main +conda env remove -n quantecon +conda env create -f environment.yml +``` diff --git a/environment-cn.yml b/environment-cn.yml index 3a5d96a4..e905291d 100644 --- a/environment-cn.yml +++ b/environment-cn.yml @@ -12,7 +12,7 @@ dependencies: - sphinx-tojupyter==0.3.1 - sphinxext-rediraffe==0.2.7 - sphinx_reredirects==0.1.4 - - sphinx-exercise==1.0.1 + - git+https://github.com/TeachBooks/sphinx-exercise.git@main - sphinx-proof==0.3.0 - ghp-import==1.1.0 - sphinxcontrib-youtube==1.4.1 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5 diff --git a/environment.yml b/environment.yml index b427f1b9..4663827b 100644 --- a/environment.yml +++ b/environment.yml @@ -10,7 +10,7 @@ dependencies: - quantecon-book-theme==0.9.2 - sphinx-tojupyter==0.3.1 - sphinxext-rediraffe==0.2.7 - - sphinx-exercise==1.0.1 + - git+https://github.com/TeachBooks/sphinx-exercise.git@main - sphinx-proof==0.3.0 - sphinxcontrib-youtube==1.4.1 - sphinx-togglebutton==0.3.2 diff --git a/lectures/_config.yml b/lectures/_config.yml index b6ef10e8..ed5e2534 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -34,7 +34,7 @@ latex: sphinx: extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinxcontrib.youtube, sphinx.ext.todo, sphinx_exercise, sphinx_proof, sphinx_togglebutton, sphinx.ext.intersphinx, sphinx_reredirects] config: - language: zh_CN + language: es # false-positive links linkcheck_ignore: ['https://online.stat.psu.edu/stat415/book/export/html/834'] bibtex_reference_style: author_year