Skip to content

Cross references are not translated #125

Closed

Description

@dtenbrinck

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

Activity

  1. added
    bug
    on Nov 9, 2024
  2. MPenaR commented on Nov 10, 2024

    @MPenaR

    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?

  3. dtenbrinck commented on Nov 10, 2024

    @dtenbrinck
    Author

    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. :)

  4. MPenaR commented on Nov 10, 2024

    @MPenaR

    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

  5. MPenaR commented on Nov 10, 2024

    @MPenaR

    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?

  6. MPenaR commented on Nov 10, 2024

    @MPenaR

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

  7. MPenaR commented on Nov 10, 2024

    @MPenaR

    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

  8. dtenbrinck commented on Nov 10, 2024

    @dtenbrinck
    Author

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

  9. MPenaR commented on Nov 10, 2024

    @MPenaR

    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?

  10. dtenbrinck commented on Nov 11, 2024

    @dtenbrinck
    Author

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

  11. MPenaR commented on Nov 11, 2024

    @MPenaR

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

    Danke schöne!

  12. MPenaR commented on Nov 11, 2024

    @MPenaR

    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?

  13. dtenbrinck commented on Nov 11, 2024

    @dtenbrinck
    Author

    I think this is fixed in this open pull request.

  14. MPenaR commented on Nov 13, 2024

    @MPenaR

    I see, thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions