Skip to content

Avoid duplicated translation entries due to the include directive #12749

@mattwang44

Description

@mattwang44

Is your feature request related to a problem? Please describe.

I encountered the issue in the CPython repository: with the recent changes related to python/cpython#122085, the include directive is introduced to the Python docs, which causes the same string appears multiple times in the PO files generated by the gettext builder. This could lead to redundant translation efforts.

Translating one instance in the PO file doesn't apply the translation to the identical strings in other PO files, which is usually appropriate since different contexts might require different translations. However, for cases caused by using include directives, the different occurrences come from the same single source and should have the same translation.

Describe the solution you'd like

If the include directive is used, the corresponding translation entry of the text from the included doc should not emerge again in the POT of those docs that include it, and the translation should be rendered successfully on the included doc and those docs that include it.

As discussed by @AA-Turner in Python Docs Discord server

Include works by inserting the raw text into the stream of the relevant document, which will be picked up multiple times by the gettext builder.
Perhaps we could attribute the text to the included document? It would require more overriding in the Include directive though.

Describe alternatives you've considered

N/A

Additional context

Take deprecations/pending-removal-in-3.14.rst:4 in the CPython doc as an example, it currently has three occurrences in the resulting POT:

Details
> cd cpython/Doc
> make clean venv gettext
> grep -rxE -C 1 --color ".*deprecations/pending-removal-in-3.14.rst:4$" build/**/*.pot
build/gettext/deprecations/index.pot-
build/gettext/deprecations/index.pot:#: ../../deprecations/pending-removal-in-3.14.rst:4
build/gettext/deprecations/index.pot-msgid ":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!argparse.BooleanOptionalAction` are ..."
--
build/gettext/deprecations/pending-removal-in-3.14.pot-
build/gettext/deprecations/pending-removal-in-3.14.pot:#: ../../deprecations/pending-removal-in-3.14.rst:4
build/gettext/deprecations/pending-removal-in-3.14.pot-msgid ":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!argparse.BooleanOptionalAction` are ..."
--
build/gettext/whatsnew/3.12.pot-#: ../../whatsnew/3.12.rst:1156
build/gettext/whatsnew/3.12.pot:#: ../../deprecations/pending-removal-in-3.14.rst:4
build/gettext/whatsnew/3.12.pot-msgid ":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!argparse.BooleanOptionalAction` are ..."

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions