Implementation of msgcat and msgmerge utilities from GNU gettext#1161
Implementation of msgcat and msgmerge utilities from GNU gettext#1161soft-suroleb wants to merge 24 commits intopython-babel:masterfrom
Conversation
…pybabel * Define the MessageConcatenation class to mimic the functionality of GNU gettext's msgcat * Define the MessageMerge class to mimic the functionality of GNU gettext's msgmerge * Implement placeholders for the main interface functions
* Add validation for main msgcat options - input_files, output_file * Temporarily set use_first option to true to avoid handling cases with different translations for the same messages
* Implement options unique, less-than, and more-than, and validate their dependencies with each other. * These options specify which messages to include in the output file. * Implement and validate options no-wrap and width. * Create a helper function _prepare that collects data on message occurrences across different catalogs. * Mark options that are already implemented #
* Implement basic functionality of msgmerge * Use and validate the main options: input-files and output-file * Use and validate options: no-wrap and width * Use and validate options: sort-output and sort-by-file, both in msgmerge and msgcat * In the basic version of working with a compendium, a translation for a message is taken from the compendium only if the resulting catalog lacks a translation.
* Create basic tests to verify the functionality of msgcat, specifically the concatenation of catalogs, merging of message flags, locations, etc. * Remove the validation of options sort-output, sort-by-file, unique, use-first, as they are initialized in the function initialize_options.
* Create basic tests to verify the functionality of msgmerge, specifically the merging of messages and their integration with a compendium. * Remove the definition of sort-output and sort-by-file, and add an additional check for input-files.
…m handling logic * Implement `update` to update the source file instead of writing to the current output file * Implement `backup` to save a backup of the source file before making any updates * Implement `c_overwrite` to use a new mode of handling the compendium, where translations from the compendium overwrite messages in the output file
* Implement a test for `msgmerge` that validates the new mode where compendium entries overwrite messages in the output PO file. * Include the `no_compendium_comment` option to ensure comments about translations sourced from the compendium are not included. * Utilize the `no-location` option to exclude location comments from the output.
* Implemented a helper function `_get_expected` to standardize the expected PO file structure. * Renamed the option `c-overwrite` to `compendium-overwrite`
* Mark the catalog as fuzzy after msgcat and msgmerge if there is at least one fuzzy message * Remove add-location as it's unnecessary
|
Hi guys! I see you marked pr but still haven't left any comments. Will it be reviewed? |
akx
left a comment
There was a problem hiding this comment.
Thank you! Some initial comments within.
tests/messages/test_frontend.py
Outdated
| assert expected_content == actual_content | ||
|
|
||
|
|
||
| class ConcatanationCatalogTestCase(unittest.TestCase): |
There was a problem hiding this comment.
The new test cases could live in new files, I think.
And if you feel like it, they could be Pytest style instead of Unittest?
There was a problem hiding this comment.
Is a new file really needed here? The file is test_frontend.py and all other tests for commands are there and it's logical that they will be there too, no?
There was a problem hiding this comment.
Well, TBH test_frontend.py could also be split into more files – smaller files tend to be easier to read and review.
* Update _prepare function in ConcatenateCatalog to check conflicting messages and to not parse po-files twice * Add _conflicts field in Catalog to mark conflicts * Update tests
* Delete unused options * Fix multiline options comments * Replace backup logic in MergeCatalog * Rename to ConcatenateCatalog
|
Made support for conflicting messages from different po-files during concatenation. If one message has different translations in different files, then the corresponding strings marked with a comment about conflict |
* Includes .rst file with detailed use cases and practical examples for pybabel's concat and merge utilities, outlining common scenarios, options, and best practices for managing PO files.
* Rename file_name to filename * Adding fuzzy flag to message parameterized in 'add_conflict' * Replace usage scenarious to cmdline.rst * Rename to ConcatenateCatalog
* Add frozen_time fixture to use freeze_time in every test
|
Guys? Will there be another round? :) |
|
@soft-suroleb Sorry, I was honeymooning in Japan for the last 3 weeks 😄 There's still a bunch of unresolved comments from me from the last round of review, I think? |
|
Oh, my congrats :) Yeah, but there is question for you in the unresolved comment |
|
Guys? @akx |
Looking at this again... Sorry, which comment? There's a bunch of comments unresolved 😅 |
|
This comment. And why bunch of comments? I think only that, all others were being resolved |
|
Things like https://github.com/python-babel/babel/pull/1161/files/dd44348272edb1d8bd86818f16ea54809cfd0851#diff-9b4dc8cb664f244c13aebdf018a3748731477a5bb7903a9677326c7ebc177f7b et al – GitHub can be confusing with the "hidden conversations" marker sometimes hiding unresolved comments |

Implementation of some features for msgcat and msgmerge to work with a compendium in PyBabel
pybabel concat
pybabel merge