Skip to content

Docs: enable translations of code blocks #123407

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

Closed
m-aciek opened this issue Aug 27, 2024 · 5 comments · Fixed by #123408
Closed

Docs: enable translations of code blocks #123407

m-aciek opened this issue Aug 27, 2024 · 5 comments · Fixed by #123408
Labels
docs Documentation in the Doc dir

Comments

@m-aciek
Copy link
Contributor

m-aciek commented Aug 27, 2024

Documentation

Code blocks, e.g. in the tutorial, include comments that are complement to the regular content of tutorial articles. An example in tutorial's introduction in section “Numbers”:

>>> 17 / 3  # classic division returns a float
5.666666666666667
>>>
>>> 17 // 3  # floor division discards the fractional part
5
>>> 17 % 3  # the % operator returns the remainder of the division
2
>>> 5 * 3 + 2  # floored quotient * divisor + remainder
17

I'd like to propose changing gettext builder configuration by allowing 'literal-block' element types translation.

The topic previously was brought up on doc-sig mailing list without a conclusion.

Linked PRs

@m-aciek m-aciek added the docs Documentation in the Doc dir label Aug 27, 2024
@zware
Copy link
Member

zware commented Aug 27, 2024

Makes sense to me. Would you like to submit a PR?

@m-aciek
Copy link
Contributor Author

m-aciek commented Aug 27, 2024

Sure! Here it is: #123408.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 31, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 31, 2024
AA-Turner pushed a commit that referenced this issue Aug 31, 2024
…) (#123531)

gh-123407: Enable translating literal and code blocks (GH-123408)
(cherry picked from commit 5332d98)

Co-authored-by: Maciej Olko <[email protected]>
AA-Turner pushed a commit that referenced this issue Aug 31, 2024
…) (#123530)

gh-123407: Enable translating literal and code blocks (GH-123408)
(cherry picked from commit 5332d98)

Co-authored-by: Maciej Olko <[email protected]>
@JulienPalard
Copy link
Member

Damned, I just noticed that, it broke the po syntax checker, the orthograph checker, the grammar checker, and sphinx-lint in python-docs-fr CI :D I'll have to find a way to disable it :D

@m-aciek
Copy link
Contributor Author

m-aciek commented Oct 31, 2024

Sorry for that! Please see my comment in sphinx-lint.

@rffontenelle
Copy link
Contributor

@JulienPalard My workaround for this issue is basically disabling 'literal-block', generating POT, updating PO, running all desired checkers, and then undoing this change in po files. Obviously, this workaround cannot be run before committing the changes.

In shell script, this means something like:

cd cpython/Doc
# comment (removing would work too)
sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py
# generate new po template files
make gettext
# update PO files from POT
sphinx-intl update --locale-dir path/to/pofiles --pot-dir build/gettext
# run the desired checkers
# finally, undo the changes
git -C path/to/pofiles checkout .

p.s.: make gettext is available as of Python 3.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants