@@ -2689,12 +2689,51 @@ These modified docstrings are created automatically together with the function
26892689definitions that are derived from the methods at import time.
26902690
26912691
2692+ .. _turtle-docstring-translation :
2693+
26922694Translation of docstrings into different languages
26932695--------------------------------------------------
26942696
2695- There is a utility to create a dictionary the keys of which are the method names
2696- and the values of which are the docstrings of the public methods of the classes
2697- Screen and Turtle.
2697+ The docstrings of the public methods of the Screen and Turtle classes, and of
2698+ the corresponding functions, can be replaced with translations, so that
2699+ :func: `help ` and IDE tooltips are shown in another language. However, only the help
2700+ text is translated, the names of the functions and methods stay the same.
2701+
2702+ Translations are distributed on PyPI in the :pypi: `turtle-translations `
2703+ package. To use them, install the package with :program: `pip ` and select the
2704+ language with the :envvar: `PYTHON_TURTLE_LANG ` environment variable. For
2705+ example, to show the help text in Spanish:
2706+
2707+ .. code-block :: console
2708+
2709+ $ python -m pip install turtle-translations
2710+ $ PYTHON_TURTLE_LANG=es python
2711+ >>> import turtle
2712+ >>> help(turtle.forward)
2713+
2714+ The language can also be set permanently with the *language * entry of the
2715+ :file: `turtle.cfg ` file (see :ref: `turtle-configuration `). If no translation
2716+ is found for the selected language, the English docstrings are kept.
2717+
2718+ To add a new language or improve an existing translation, see the
2719+ contribution instructions in the :pypi: `turtle-translations ` project.
2720+
2721+ A translation is a docstring dictionary. It is a top-level module named
2722+ :samp: `turtle_docstringdict_{ language } .py ` on :data: `sys.path ` defining a
2723+ dictionary named ``docsdict ``, the keys of which are method names such as
2724+ ``Turtle.forward `` and the values of which are the translated docstrings. It is
2725+ read in at import time. Entries naming a method which does not exist in the
2726+ running version are ignored.
2727+
2728+ .. versionchanged :: 3.16
2729+ Entries naming an unknown method are ignored instead of reported.
2730+
2731+ .. envvar :: PYTHON_TURTLE_LANG
2732+
2733+ The name of the language to read the translation for. It takes precedence
2734+ over the *language * entry of the :file: `turtle.cfg ` file.
2735+
2736+ .. versionadded :: 3.16
26982737
26992738.. function :: write_docstringdict(filename="turtle_docstringdict")
27002739
@@ -2706,17 +2745,8 @@ Screen and Turtle.
27062745 Python script :file: `{ filename } .py `. It is intended to serve as a template
27072746 for translation of the docstrings into different languages.
27082747
2709- If you (or your students) want to use :mod: `!turtle ` with online help in your
2710- native language, you have to translate the docstrings and save the resulting
2711- file as e.g. :file: `turtle_docstringdict_german.py `.
2712-
2713- If you have an appropriate entry in your :file: `turtle.cfg ` file this dictionary
2714- will be read in at import time and will replace the original English docstrings.
2715-
2716- At the time of this writing there are docstring dictionaries in German and in
2717- Italian. (Requests please to glingl@aon.at.)
2718-
27192748
2749+ .. _turtle-configuration :
27202750
27212751How to configure Screen and Turtles
27222752-----------------------------------
@@ -2767,9 +2797,9 @@ Short explanation of selected entries:
27672797 the cfg file).
27682798- If you want to reflect the turtle its state, you have to use ``resizemode =
27692799 auto ``.
2770- - If you set e.g. `` language = italian `` the docstringdict
2771- :file: ` turtle_docstringdict_italian.py ` will be loaded at import time (if
2772- present on the import path, e.g. in the same directory as :mod: ` ! turtle`) .
2800+ - The * language * entry selects the language of the docstrings, unless the
2801+ :envvar: ` PYTHON_TURTLE_LANG ` environment variable is set. See
2802+ :ref: ` turtle-docstring-translation ` for more information .
27732803- The entries *exampleturtle * and *examplescreen * define the names of these
27742804 objects as they occur in the docstrings. The transformation of
27752805 method-docstrings to function-docstrings will delete these names from the
0 commit comments