Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross references are not translated #125

Open
dtenbrinck opened this issue Nov 9, 2024 · 13 comments · May be fixed by #126
Open

Cross references are not translated #125

dtenbrinck opened this issue Nov 9, 2024 · 13 comments · May be fixed by #126
Labels
bug Something isn't working

Comments

@dtenbrinck
Copy link

Describe the bug

context
When I compile my markdown files to HTML using sphinx_proof with language settings to German, the titles of most of the proof boxes are translated correctly (some are missing) but the cross references to these boxes stay in English language.

expectation
I expect that the titles in cross references are also translated according to the language settings.

problem
This gives inconsistent results in books that are not written in English language.

sphinx_proof_bug

Reproduce the bug

  1. Add the following to your _config.yml:
sphinx:
  extra_extensions:
    - sphinx_proof
  config:
    language: de
  1. Compile book to HTML with jupyter-book build .

  2. Observe build result in folder _build/html/

List your environment

Version of sphinx-proof: 0.2.0

jupyter-book --version
Jupyter Book      : 1.0.3
External ToC      : 1.0.1
MyST-Parser       : 2.0.0
MyST-NB           : 1.1.2
Sphinx Book Theme : 1.1.3
Jupyter-Cache     : 1.0.0
NbClient          : 0.10.0

python --version
Python 3.12.7

Operating System: ArchLinux
@MPenaR
Copy link

MPenaR commented Nov 10, 2024

I have the same setting but with "language: es" expecting to get the spanish but they are in english (both titles and references).

Is this feature only available in german?

@dtenbrinck
Copy link
Author

dtenbrinck commented Nov 10, 2024

Probably you are using the pip installed package of sphinx-proof, which unfortunately doesn't include the directory sphinx_proof/translations/jsons with the needed translations (you can verify on PyPI).
To make this work you need to clone this repository and add Spanish translations in some of the json files as follows:

  1. Clone the repository, e.g., git clone https://github.com/executablebooks/sphinx-proof.git ~/sphinx-proof
  2. Add translations in the files in ~/sphinx-proof/sphinx_proof/translations/jsons/ (see my commit for example)
  3. Generate the translation binaries via python ~/sphinx-proof/sphinx_proof/translations/_convert.py
  4. Link the package into your virtual environment, e.g., via ln -s ~/sphinx-proof/sphinx_proof ~/my_book_project/.venv/lib/python3.12/site-packages/sphinx_proof
  5. Configure your sphinx settings in the file ~/my_book_project/_config.yml with:
sphinx:
  extra_extensions:
    - sphinx_proof
  config:
    language: es

It would be great if you could create a pull request for your contribution of Spanish translations. :)

@MPenaR
Copy link

MPenaR commented Nov 10, 2024

Thank you for the detailed explanation, that way not only will be able to have spanish translations but I also learn XD

I'll try to do it this evening

@MPenaR
Copy link

MPenaR commented Nov 10, 2024

When I run the python _convert.py it complains about not finding the file or directory msgfmt. Do you know which is the minimal enviroment I need?

@MPenaR
Copy link

MPenaR commented Nov 10, 2024

For someone in the future, in debian the utility msgfmt is installed with the package gettext

@MPenaR
Copy link

MPenaR commented Nov 10, 2024

It would be great if you could create a pull request for your contribution of Spanish translations. :)

I think I did it correctly. It's in pull request #127

@dtenbrinck
Copy link
Author

Great work! I hope our pull requests will be merged soon into sphinx-proof. 👍

@MPenaR
Copy link

MPenaR commented Nov 10, 2024

I've just realised that my changes only affect the titles of the directives, but not the cross references. But if I understood it correctly, once my code and your code get merged the spanish cross references will also work.

Am I right?

@dtenbrinck
Copy link
Author

Yes, my changes should work for any translation. You can test it by merging my commit into your code.

@MPenaR
Copy link

MPenaR commented Nov 11, 2024

Done in commit d1c7e9c and working nicely in my book ( it also passes the tox tests)

Danke schöne!

@MPenaR
Copy link

MPenaR commented Nov 11, 2024

At the beggining of a "proof" directive it is still read proof independently of the language used:
imagen

Is this a feature or a bug?

@dtenbrinck
Copy link
Author

I think this is fixed in this open pull request.

@MPenaR
Copy link

MPenaR commented Nov 13, 2024

I see, thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants