Repository navigation
Read previous msgids (#|) from PO files and keep them on update - #1466
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
read_po stored "#| msgid ..." lines as user comments, so the next write_po turned them into "# | msgid ..." translator comments that stay forever. Parse them into Message.previous_id, and keep the previous_id of a message that is still fuzzy in Catalog.update, so repeated "pybabel update --previous" runs keep the #| lines like msgmerge does. write_po wrapped a long previous msgid like a comment, splitting its quoted strings; write one "#| " line per normalized line instead, so it reads back unchanged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pybabel update --previouswrites the old msgid of a fuzzy message as#| msgid ..., butread_podoesn't parse#|lines and stores them as user comments. The nextupdate --previouswrites them back as translator comments:The
# | msgidline then stays in the catalog as a translator comment even after the string is fixed. The same happens to#|lines written by GNUmsgmerge --previous.Two changes:
read_poparses#| msgid/#| msgid_plural(and their continuation lines) intoMessage.previous_id.Messagehas no field for a previous msgctxt, so a#| msgctxtline is dropped instead of becoming a comment.Catalog.updatekeepsprevious_idfor a message that matches exactly but is still fuzzy, so a second run keeps the#|line, like msgmerge.write_powrapped a long previous msgid with the comment wrapper, which splits it in the middle of the quoted strings (#| msgid "" "Save the file ... window so/#| " "nothing is lost"). It now writes one#|line per line of the normalized string, the way msgmerge does, so it reads back unchanged.With both, three
pybabel update --previousruns on the example above keep#| msgid "Save the file".test_previous_msgid_roundtrip,test_long_previous_msgid_roundtripandtest_catalog_update_keeps_previous_id_of_fuzzy_messagefail without the change.pytest tests/messages: the only failure istest_4_num_plurals_checkers, which fails the same way on master here (my locale data comes from the installed Babel 2.17.0, as the checkout has none).