-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-85012: Properly reset msgctxt
when compiling messages with msgfmt
#130525
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
Conversation
cc @StanFromIreland @m-aciek just in case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 69402a5 changeset does not look particularly readable. For some reasons this change causes changing the order of the _catalog
items, so it is difficult to see changes in values if the items are reordered. Do you know why is it? Can the order be made more stable?
There are no new tests, so we can only visually control that the behavior is correct. But if in future the order will be change unpredictably, we can miss a regression. Please add a test for the change, preferably a translation test that does not depend on implementation details of GNUTranslations
.
It was sorted, the issue was that the message context was/is part of the message and so fixing that resulted in many messages being reordered. I changed the sorting to always put plurals at the end which produces IMO a much more readable diff: 8295b2b
Added in 97d0a0f. It tests all mesages from the source PO file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @tomasr8 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Thanks @tomasr8 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @tomasr8 and @serhiy-storchaka, I could not cleanly backport this to
|
Sorry, @tomasr8 and @serhiy-storchaka, I could not cleanly backport this to
|
… with msgfmt (pythonGH-130525) Add also human-readable snapshots for tests. (cherry picked from commit 7ea6e88) Co-authored-by: Tomas R. <[email protected]>
GH-131205 is a backport of this pull request to the 3.13 branch. |
… with msgfmt (pythonGH-130525) Add also human-readable snapshots for tests. (cherry picked from commit 7ea6e88) Co-authored-by: Tomas R. <[email protected]>
GH-131206 is a backport of this pull request to the 3.12 branch. |
Thanks for dealing with the backports Serhiy, I was going to do it but you beat me to it 😄 |
…msgfmt (GH-130525) (GH-131206) Add also human-readable snapshots for tests. (cherry picked from commit 7ea6e88) Co-authored-by: Tomas R <[email protected]>
…msgfmt (GH-130525) (GH-131205) Add also human-readable snapshots for tests. (cherry picked from commit 7ea6e88) Co-authored-by: Tomas R <[email protected]>
|
… with msgfmt (pythonGH-130525) (pythonGH-131206) Add also human-readable snapshots for tests. (cherry picked from commit 7ea6e88) Co-authored-by: Tomas R <[email protected]>
…sgfmt (pythonGH-130525) Add also human-readable snapshots for tests.
…sgfmt (pythonGH-130525) Add also human-readable snapshots for tests.
I realized that the downside of only having binary snapshots is that it's much more difficult to review any changes. So I added human-readable snapshots as well in this PR.
These snapshots are just JSON dumps of
GNUTranslations._catalog
when the MO file is read back. (I thought about using PO files for the snapshots but that would require some additional changes in pygettext so I opted for this for now)I first generated the new snapshots and then applied the fix so you can see the diff in the snapshots here: 69402a5
What you're looking for is correct
msgctxt
(the part before\u0004
in each message). This is the source file for reference:https://github.com/python/cpython/blob/main/Lib/test/test_tools/msgfmt_data/general.po