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

Implementation of msgcat and msgmerge utilities from GNU gettext #1161

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

soft-suroleb
Copy link

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

pybabel concat

  • Allows concatenating multiple .po files into one.
  • In case of translation conflicts, the translation from the first file is taken, as if the use-first option is set to true. Flags, locations, and other information in messages are combined.
  • Implemented options:
    • output-file
    • less-than
    • more-than
    • unique
    • use-first
    • no-location
    • width
    • no-wrap
    • sort-output
    • sort-by-file

pybabel merge

  • Enables merging files using a compendium for translation memory.
  • The compendium can be used in two modes:
    • Default mode: Translations from the compendium are taken if absent in the output file.
    • Compendium overwrite mode: With the compendium-overwrite option, translations in the compendium are considered primary and overwrite those in the output file. If a translation is taken from the compendium, a comment is added specifying the source.
  • Implemented options:
    • input-files
    • compendium
    • compendium-overwrite
    • no-compendium-comment
    • update
    • output-file
    • backup
    • suffix
    • no-fuzzy-matching
    • no-location
    • width
    • no-wrap
    • sort-output
    • sort-by-file

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants