|
| 1 | +# Testing sphinx-exercise Internationalization Support |
| 2 | + |
| 3 | +This branch (`tst-sphinx-exercise`) is configured to test the internationalization (i18n) support for sphinx-exercise from PR #75. |
| 4 | + |
| 5 | +## Changes Made |
| 6 | + |
| 7 | +The environment files have been updated to install sphinx-exercise directly from the TeachBooks fork that includes i18n support: |
| 8 | + |
| 9 | +- **environment.yml**: Updated to use `git+https://github.com/TeachBooks/sphinx-exercise.git@main` |
| 10 | +- **environment-cn.yml**: Updated to use `git+https://github.com/TeachBooks/sphinx-exercise.git@main` |
| 11 | + |
| 12 | +## Setup Instructions |
| 13 | + |
| 14 | +1. **Recreate the conda environment** to install the development version: |
| 15 | + ```bash |
| 16 | + conda env remove -n quantecon |
| 17 | + conda env create -f environment.yml |
| 18 | + # Or for China mirror: |
| 19 | + # conda env create -f environment-cn.yml |
| 20 | + ``` |
| 21 | + |
| 22 | +2. **Activate the environment**: |
| 23 | + ```bash |
| 24 | + conda activate quantecon |
| 25 | + ``` |
| 26 | + |
| 27 | +3. **Verify the installation**: |
| 28 | + ```bash |
| 29 | + python -c "import sphinx_exercise; print(sphinx_exercise.__version__)" |
| 30 | + ``` |
| 31 | + |
| 32 | +## Testing i18n Support |
| 33 | + |
| 34 | +The configuration in `lectures/_config.yml` already includes: |
| 35 | +- `language: zh_CN` - This sets the Sphinx language to Chinese |
| 36 | +- `sphinx_exercise` extension is loaded |
| 37 | + |
| 38 | +With the PR #75 changes, exercise and solution labels should now automatically translate to Chinese when building the documentation. |
| 39 | + |
| 40 | +### Build the documentation |
| 41 | + |
| 42 | +```bash |
| 43 | +cd lectures |
| 44 | +jupyter-book build . |
| 45 | +``` |
| 46 | + |
| 47 | +### What to Check |
| 48 | + |
| 49 | +Look for translated labels in the built HTML: |
| 50 | +- **Exercise** should appear as the Chinese equivalent (练习) |
| 51 | +- **Solution to** should appear as the Chinese equivalent (解答) |
| 52 | + |
| 53 | +You can inspect the HTML output in `lectures/_build/html/` or check specific lecture files that contain exercises. |
| 54 | + |
| 55 | +## PR Reference |
| 56 | + |
| 57 | +- **Pull Request**: https://github.com/executablebooks/sphinx-exercise/pull/75 |
| 58 | +- **Issue**: https://github.com/executablebooks/sphinx-exercise/issues/73 |
| 59 | +- **Branch**: TeachBooks:main |
| 60 | + |
| 61 | +## Features Added by PR #75 |
| 62 | + |
| 63 | +1. Translation infrastructure using Sphinx's i18n system |
| 64 | +2. Support for multiple languages including Chinese (zh_CN) |
| 65 | +3. Automatic translation of "Exercise" and "Solution to" labels |
| 66 | +4. Translation files in `.po` format for various languages |
| 67 | + |
| 68 | +## Reverting Changes |
| 69 | + |
| 70 | +To revert back to the stable version: |
| 71 | + |
| 72 | +```bash |
| 73 | +git checkout main |
| 74 | +conda env remove -n quantecon |
| 75 | +conda env create -f environment.yml |
| 76 | +``` |
0 commit comments