Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions TESTING_SPHINX_EXERCISE_I18N.md
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 1 addition & 1 deletion environment-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading