sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.57k stars 2.12k forks source link

I18nBuilder (-b gettext) saves non-unique messages to *.pot files. #653

Closed shimizukawa closed 9 years ago

shimizukawa commented 9 years ago

The I18nBuilder class uses the ID of a doctree node to hash messages. This may lead to duplicate messages in the *.pot file:

> msginit -l de -i api.pot
api.pot:92: duplicate message definition...
api.pot:57: ...this is the location of the first definition
api.pot:252: duplicate message definition...
api.pot:189: ...this is the location of the first definition
api.pot:364: duplicate message definition...
api.pot:133: ...this is the location of the first definition
api.pot:468: duplicate message definition...
api.pot:73: ...this is the location of the first definition
api.pot:576: duplicate message definition...
api.pot:157: ...this is the location of the first definition
msginit: found 5 fatal errors

shimizukawa commented 9 years ago

From Robert Lehmann on 2011-04-14 17:57:12+00:00

Reproduced bug with the current Sphinx docs. It is a regression introduced during versioning support: previously, all nodes were hashed by their message string only and duplicates were squashed. This is no longer the case with unique IDs tracking nodes along document changes.

Formerly, {{{catalog}}} was a list of messages and blindly merged all duplicate messages. It simulated an ordered set as message ordering should be retained in catalogs (and if they occurred twice they only showed up at the first slot). This behaviour was useful and should be restored.

UIDs should be merged into the comments of their corresponding message. Using them as the {{{msgid}}} itself would hide stale messages from translators without tool support. They //could// be supplied as a {{{msgctxt}}} (which is not natively supported by Python's {{{gettext}}}) but that would needlessly separate identical messages (eg. in glossaries).

Version tracking is hard, let's go shopping!

shimizukawa commented 9 years ago

From Kouhei Sutou on 2011-05-08 09:08:01+00:00

I've created a patch to fix it: https://bitbucket.org/kou/sphinx/changeset/9710b94ba9dd. It is included in my i18n-generate-valid-pot branch: https://bitbucket.org/kou/sphinx/src/01a51aa9f73e

The branch also has reference comment support described in GNU gettext document: "3 The Format of PO Files" http://www.gnu.org/s/hello/manual/gettext/PO-Files.html

shimizukawa commented 9 years ago

From Kouhei Sutou on 2011-05-15 10:56:39+00:00

It seems that this issue has been resolved because patches in my branches are pulled. Robert, could you confirm it?

shimizukawa commented 9 years ago

From Robert Lehmann on 2011-07-06 07:22:51+00:00

Thanks all, this issue is now resolved. Special thanks go out to <>, <>, and <> for submitting patches.

See <<cset 0c9c9e8bee0f7e44fd3c095f38c2f0f061dddc51>> and the following commits for details.