@@ -2675,12 +2675,47 @@ These modified docstrings are created automatically together with the function
26752675definitions that are derived from the methods at import time.
26762676
26772677
2678+ .. _turtle-docstring-translation :
2679+
26782680Translation of docstrings into different languages
26792681--------------------------------------------------
26802682
2681- There is a utility to create a dictionary the keys of which are the method names
2682- and the values of which are the docstrings of the public methods of the classes
2683- Screen and Turtle.
2683+ The docstrings of the public methods of the Screen and Turtle classes, and of
2684+ the functions derived from them, can be replaced by translations, so that
2685+ :func: `help ` and IDE tooltips are shown in another language.
2686+
2687+ The translations are not part of Python. They are distributed on PyPI in the
2688+ :pypi: `turtle-translations ` package, which holds the docstring dictionaries of
2689+ all available languages. To use it, you must first install it with :program: `pip `::
2690+
2691+ python -m pip install turtle-translations
2692+
2693+ The language is taken from the :envvar: `PYTHON_TURTLE_LANG ` environment
2694+ variable, or, if that is unset, from the ``language `` entry of the
2695+ :file: `turtle.cfg ` file. If no docstring dictionary is found for it, the
2696+ English docstrings are kept.
2697+
2698+ .. envvar :: PYTHON_TURTLE_LANG
2699+
2700+ The name of the language to read the docstring dictionary for.
2701+
2702+ .. versionadded :: 3.16
2703+
2704+ A docstring dictionary is a module defining a dictionary named ``docsdict ``,
2705+ the keys of which are method names such as ``Turtle.forward `` and the values of
2706+ which are the translated docstrings. It is looked up on :data: `sys.path `, first
2707+ as the submodule of that name of a package named :mod: `!turtle_translations `,
2708+ then as a top-level module named :samp: `turtle_docstringdict_{ language } .py `,
2709+ and is read in at import time. Entries naming a method which does not exist in
2710+ the running version are ignored.
2711+
2712+ .. versionchanged :: 3.16
2713+ The docstring dictionary may also be provided as a submodule of a
2714+ :mod: `!turtle_translations ` package, and entries naming an unknown method
2715+ are ignored instead of reported.
2716+
2717+ To translate the docstrings into a language which is not available yet, write
2718+ out a template with :func: `write_docstringdict ` and translate its values.
26842719
26852720.. function :: write_docstringdict(filename="turtle_docstringdict")
26862721
@@ -2692,17 +2727,6 @@ Screen and Turtle.
26922727 Python script :file: `{ filename } .py `. It is intended to serve as a template
26932728 for translation of the docstrings into different languages.
26942729
2695- If you (or your students) want to use :mod: `!turtle ` with online help in your
2696- native language, you have to translate the docstrings and save the resulting
2697- file as e.g. :file: `turtle_docstringdict_german.py `.
2698-
2699- If you have an appropriate entry in your :file: `turtle.cfg ` file this dictionary
2700- will be read in at import time and will replace the original English docstrings.
2701-
2702- At the time of this writing there are docstring dictionaries in German and in
2703- Italian. (Requests please to glingl@aon.at.)
2704-
2705-
27062730
27072731How to configure Screen and Turtles
27082732-----------------------------------
@@ -2753,9 +2777,9 @@ Short explanation of selected entries:
27532777 the cfg file).
27542778- If you want to reflect the turtle its state, you have to use ``resizemode =
27552779 auto ``.
2756- - If you set e.g. `` language = italian `` the docstringdict
2757- :file: ` turtle_docstringdict_italian.py ` will be loaded at import time (if
2758- present on the import path, e.g. in the same directory as :mod: ` ! turtle`) .
2780+ - The * language * entry selects the language of the docstrings, unless the
2781+ :envvar: ` PYTHON_TURTLE_LANG ` environment variable is set. See
2782+ :ref: ` turtle-docstring-translation ` for more information .
27592783- The entries *exampleturtle * and *examplescreen * define the names of these
27602784 objects as they occur in the docstrings. The transformation of
27612785 method-docstrings to function-docstrings will delete these names from the
0 commit comments