msgattrib
Update message catalogs attributes in gettext
SYNOPSIS
msgattrib [OPTION]... [INPUTFILE]
PARAMETERS
-a, --set-attribute=ATTRIBUTE
Set a specified attribute (e.g., "fuzzy", "obsolete", "c-format") on matching entries.
-D, --drop-attribute=ATTRIBUTE
Remove a specified attribute (e.g., "fuzzy", "obsolete") from matching entries.
-F, --only-fuzzy
Keep only entries marked as fuzzy.
-f, --only-nonfuzzy
Keep only entries not marked as fuzzy.
-O, --only-obsolete
Keep only obsolete entries.
-o, --only-nonobsolete
Keep only non-obsolete entries.
-u, --untranslated
Keep only entries that are untranslated.
-t, --translated
Keep only entries that are translated.
-E, --only-empty-output
Keep only entries with an empty translation string.
-e, --only-nonempty-output
Keep only entries with a non-empty translation string.
-A, --only-assigned
Keep only entries with an assigned translator comment.
-d, --only-deassigned
Keep only entries without an assigned translator comment.
--statistics
Print statistics about the PO file content instead of the modified entries.
-o, --output-file=FILE
Write output to the specified file instead of standard output.
-i, --input-file=FILE
Read input from the specified file instead of standard input.
DESCRIPTION
msgattrib is a utility from the GNU gettext toolset, designed to manipulate and filter entries within a PO (Portable Object) file. PO files are standard formats for storing translatable strings and their translations in internationalization (i18n) workflows.
This command allows users to perform operations such as setting or dropping specific attributes (like fuzzy, obsolete, or comment flags) on message entries. Beyond modification, msgattrib can also filter entries, enabling users to extract only those that match certain criteria, for example, only fuzzy entries, only translated ones, or only those without a translation.
This makes it an invaluable tool for translators and localization engineers to manage the state of their translation files, perform quality checks, or prepare files for specific stages of the translation process. It typically takes a PO file as input and writes the modified or filtered content to standard output or a specified output file.
CAVEATS
msgattrib primarily operates on PO files; it does not directly handle MO (Machine Object) files. Filtering options within the same category (e.g., --only-fuzzy and --only-nonfuzzy) are mutually exclusive and using them together may yield unexpected results or an empty output. Care must be taken when modifying critical attributes like fuzzy, as it directly impacts the readiness and quality status of translations in a workflow.
COMMON USE CASES
Marking entries as fuzzy: After a source string change, msgmerge often marks affected translations as fuzzy. msgattrib can be used to manually set or unset this flag for specific entries.
Filtering for review: Translators or reviewers can use --only-fuzzy or --untranslated to create a subset of the PO file that requires immediate attention.
Cleaning up obsolete entries: Obsolete entries are not used but kept for reference. --only-obsolete can filter them out, or -D obsolete could remove the flag if they are no longer needed for history.
Automated workflows: Integrating msgattrib into scripts allows for automated checks and modifications of PO files based on project-specific rules or build processes.
ATTRIBUTE TYPES
The ATTRIBUTE argument for --set-attribute and --drop-attribute typically refers to flags like "fuzzy" or "obsolete", but can also include format flags (e.g., "c-format", "php-format", "java-format") that indicate the type of format string used in the message. These format flags are usually detected by xgettext but can be manually manipulated if needed.
HISTORY
The msgattrib command is an integral part of the GNU gettext localization framework. Gettext itself was initiated by Sun Microsystems in the early 1990s and later adopted and extended by the GNU project. It became a de facto standard for internationalization in Unix-like operating systems and many open-source projects. msgattrib emerged as part of the gettext-tools suite, providing a granular way to manage the state and properties of individual translation entries within PO files. Its development has closely tracked the evolution of the gettext system, aiming to offer robust and flexible command-line tools for translators and developers to automate and streamline localization workflows, particularly concerning quality control and workflow management of translation memory.