Skip to content
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

"Untranslated" class added on paragraphs which are translated but not different from original #11546

Closed
jeanas opened this issue Aug 1, 2023 · 1 comment · Fixed by #11580

Comments

@jeanas
Copy link
Contributor

jeanas commented Aug 1, 2023

Describe the bug

As a follow-up to #11509: a little quirk is that if you translate a paragraph, but the translation is the same as the original, which can happen, e.g., with paragraphs like

You can install packages from

- `PyPI <https://pypi.org>`_
...

then the paragraph is wrongly marked as "untranslated".

How to Reproduce

conf.py:

translation_progress_classes = True

index.rst:

$ cat index.rst 
Foo bar baz.

Foo bar baz 2.

Foo bar baz 3.

locales/fr/LC_MESSAGES/index.po:

# SOME DESCRIPTIVE TITLE.
# Copyright (C)
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-01 17:07+0200\n"
"PO-Revision-Date: 2023-08-01 17:08+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../index.rst:1
msgid "Foo bar baz."
msgstr "Foo bar baz translated."

#: ../index.rst:3
msgid "Foo bar baz 2."
msgstr ""

#: ../index.rst:5
msgid "Foo bar baz 3."
msgstr "Foo bar baz 3."

Build command: sphinx-build -Dlanguage=fr . build

Excerpt from HTML output:

  <p class="translated">Foo bar baz translated.</p>
<p class="untranslated">Foo bar baz 2.</p>
<p class="untranslated">Foo bar baz 3.</p>

Environment Information

Platform:              linux; (Linux-6.3.12-200.fc38.x86_64-x86_64-with-glibc2.37)
Python version:        3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)])
Python implementation: CPython
Sphinx version:        7.1.1
Docutils version:      0.20.1
Jinja2 version:        3.1.2
Pygments version:      2.15.1

Sphinx extensions

None

Additional context

As far as I can see, in the Python gettext API, the original message is returned unchanged when there is no translation, which doesn't allow distinguishing this case from the case where the translation is present but happens to be the same as the original.

However, it should be possible to force a distinction to be made using a fallback:

https://docs.python.org/3/library/gettext.html#gettext.NullTranslations.add_fallback

(this is the approach I used in my hand-made extension for translation progress before #11509).

@AA-Turner

@jeanas jeanas changed the title "Untranslated" class added on paragraph which are translated but not different from original "Untranslated" class added on paragraphs which are translated but not different from original Aug 1, 2023
@picnixz
Copy link
Member

picnixz commented Aug 10, 2023

+1 for this.

Although I never use localization, it is quite important if two acronyms are used the same way in two languages. For instance NATO in English translates to NATO in German but OTAN in French. And if there are a lot of NATO occurrences, you might end up having an incorrect amount of "untranslated" content (which may not be that good I think).

@AA-Turner AA-Turner added this to the some future version milestone Aug 11, 2023
AA-Turner added a commit that referenced this issue Aug 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants