Skip to content

gh-156360: Improve turtle translation support - #156422

Open
StanFromIreland wants to merge 8 commits into
python:mainfrom
StanFromIreland:turtle/translations-plumbing
Open

StanFromIreland wants to merge 8 commits into
python:mainfrom
StanFromIreland:turtle/translations-plumbing

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

@read-the-docs-community

read-the-docs-community Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Comment thread Lib/turtle.py Outdated
Comment thread Lib/turtle.py Outdated
Comment thread Doc/library/turtle.rst Outdated
Comment thread Doc/library/turtle.rst Outdated
@m-aciek m-aciek added the stdlib Standard Library Python modules in the Lib/ directory label Aug 26, 2026
@StanFromIreland StanFromIreland removed the stdlib Standard Library Python modules in the Lib/ directory label Aug 26, 2026
@StanFromIreland
StanFromIreland marked this pull request as ready for review September 13, 2026 17:29
@StanFromIreland

Copy link
Copy Markdown
Member Author

@m-aciek can you please take a look?

@m-aciek m-aciek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking it through, I don’t think we need to change the existing loader. The turtle-translations package can provide modules such as turtle_docstringdict_pl.py containing a docsdict dictionary, which older Python versions can already load through turtle.cfg. This would let us distribute and update translations independently of Python releases while preserving compatibility with the existing loading mechanism.

Documenting the package would still help users discover and install translations, and an environment variable for selecting the language could be a convenient addition. Could we focus this PR on those improvements and keep the existing loader?

@StanFromIreland

Copy link
Copy Markdown
Member Author

I'm still not convinced, however, for two reasons:

  • it's namespace clutter, which isn't ideal, especially when we'll have quite a few translations.
  • unless we release translations specifically for older versions, they won't load.

@m-aciek

m-aciek commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

I agree that the top-level modules introduce some namespace clutter; that seems to be the main trade-off of preserving compatibility with the existing loader.

For the version-compatibility issue, though, I don't think this necessarily requires separate releases of turtle-translations for older Python versions. A single release could ship version-specific docsdict data and have the turtle_docstringdict_<lang> modules select the appropriate one based on sys.version_info.

The version-specific dictionaries could also be generated from the common translation catalogue against the API exposed by each supported turtle version, so entries for newer methods simply wouldn't be present when loaded by an older Python.

@StanFromIreland

Copy link
Copy Markdown
Member Author

Ok, let's try that for now, and we can always iterate since there's quite a bit of time till the feature freeze. I've made the switch, please review.

@m-aciek m-aciek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. Could we make the documentation easier to follow for beginners by leading with a complete example of enabling a translation, followed by a link to instructions for contributing a new language? The dictionary format and module lookup details could go alongside write_docstringdict().

In the introduction, “translations” would be clearer than “translation catalogues” or “docstring dictionaries”. It would also help to explain that only the help text is translated; Python function names remain unchanged.

Comment thread Doc/library/turtle.rst Outdated
Comment thread Misc/NEWS.d/next/Library/2026-08-26-15-28-59.gh-issue-156360.ctZMHf.rst Outdated
Comment thread Lib/turtle.py
Comment thread Doc/library/turtle.rst Outdated
Comment thread Doc/library/turtle.rst Outdated
Comment thread Doc/library/turtle.rst Outdated
Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
@StanFromIreland

Copy link
Copy Markdown
Member Author

I reshuffled some things around, thanks for the review.

I'd like to wait a little before we start deprecating things, and I need to think a bit more about what to do with the eval.

@m-aciek m-aciek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 I left yet couple of non-blocking suggestions.

Comment thread Doc/library/turtle.rst
Comment thread Doc/library/turtle.rst Outdated
Comment thread Lib/test/test_turtle.py Outdated
Comment thread Doc/library/turtle.rst
Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants