{
    "mode": "info",
    "parameter": "msgfilter",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/msgfilter/json",
    "generated": "2026-11-09T23:24:49Z",
    "sections": {
        "File: gettext.info,  Node: msgfilter Invocation,  Next: msguniq Invocation,  Prev: msggrep Invocation,  Up: Manipulating": {
            "content": "",
            "subsections": [
                {
                    "name": "9.4 Invoking the 'msgfilter' Program",
                    "content": "msgfilter [OPTION] FILTER [FILTER-OPTION]\n\nThe 'msgfilter' program applies a filter to all translations of a\ntranslation catalog.\n\nDuring each FILTER invocation, the environment variable\n'MSGFILTERMSGID' is bound to the message's msgid, and the environment\nvariable 'MSGFILTERLOCATION' is bound to the location in the PO file of\nthe message.  If the message has a context, the environment variable\n'MSGFILTERMSGCTXT' is bound to the message's msgctxt, otherwise it is\nunbound.  If the message has a plural form, environment variable\n'MSGFILTERMSGIDPLURAL' is bound to the message's msgidplural and\n'MSGFILTERPLURALFORM' is bound to the order number of the plural\nactually processed (starting with 0), otherwise both are unbound.  If\nthe message has a previous msgid (added by 'msgmerge'), environment\nvariable 'MSGFILTERPREVMSGCTXT' is bound to the message's previous\nmsgctxt, 'MSGFILTERPREVMSGID' is bound to the previous msgid, and\n'MSGFILTERPREVMSGIDPLURAL' is bound to the previous msgidplural.\n\n\n'-i INPUTFILE'\n'--input=INPUTFILE'\nInput PO file.\n\n'-D DIRECTORY'\n'--directory=DIRECTORY'\nAdd DIRECTORY to the list of directories.  Source files are\nsearched relative to this list of directories.  The resulting '.po'\nfile will be written relative to the current directory, though.\n\nIf no INPUTFILE is given or if it is '-', standard input is read.\n\n\n'-o FILE'\n'--output-file=FILE'\nWrite output to specified file.\n\nThe results are written to standard output if no output file is\nspecified or if it is '-'.\n\n\nThe FILTER can be any program that reads a translation from standard\ninput and writes a modified translation to standard output.  A\nfrequently used filter is 'sed'.  A few particular built-in filters are\nalso recognized.\n\n'--newline'\nAdd newline at the end of each input line and also strip the ending\nnewline from the output line.\n\nNote: If the filter is not a built-in filter, you have to care about\nencodings: It is your responsibility to ensure that the FILTER can cope\nwith input encoded in the translation catalog's encoding.  If the FILTER\nwants input in a particular encoding, you can in a first step convert\nthe translation catalog to that encoding using the 'msgconv' program,\nbefore invoking 'msgfilter'.  If the FILTER wants input in the locale's\nencoding, but you want to avoid the locale's encoding, then you can\nfirst convert the translation catalog to UTF-8 using the 'msgconv'\nprogram and then make 'msgfilter' work in an UTF-8 locale, by using the\n'LCALL' environment variable.\n\nNote: Most translations in a translation catalog don't end with a\nnewline character.  For this reason, unless the '--newline' option is\nused, it is important that the FILTER recognizes its last input line\neven if it ends without a newline, and that it doesn't add an undesired\ntrailing newline at the end.  The 'sed' program on some platforms is\nknown to ignore the last line of input if it is not terminated with a\nnewline.  You can use GNU 'sed' instead; it does not have this\nlimitation.\n\n\n'-e SCRIPT'\n'--expression=SCRIPT'\nAdd SCRIPT to the commands to be executed.\n\n'-f SCRIPTFILE'\n'--file=SCRIPTFILE'\nAdd the contents of SCRIPTFILE to the commands to be executed.\n\n'-n'\n'--quiet'\n'--silent'\nSuppress automatic printing of pattern space.\n\n\nThe filter 'recode-sr-latin' is recognized as a built-in filter.  The\ncommand 'recode-sr-latin' converts Serbian text, written in the Cyrillic\nscript, to the Latin script.  The command 'msgfilter recode-sr-latin'\napplies this conversion to the translations of a PO file.  Thus, it can\nbe used to convert an 'sr.po' file to an 'sr@latin.po' file.\n\nThe filter 'quot' is recognized as a built-in filter.  The command\n'msgfilter quot' converts any quotations surrounded by a pair of '\"',\n''', and '`'.\n\nThe filter 'boldquot' is recognized as a built-in filter.  The\ncommand 'msgfilter boldquot' converts any quotations surrounded by a\npair of '\"', ''', and '`', also adding the VT100 escape sequences to the\ntext to decorate it as bold.\n\nThe use of built-in filters is not sensitive to the current locale's\nencoding.  Moreover, when used with a built-in filter, 'msgfilter' can\nautomatically convert the message catalog to the UTF-8 encoding when\nneeded.\n\n\n'-P'\n'--properties-input'\nAssume the input file is a Java ResourceBundle in Java\n'.properties' syntax, not in PO file syntax.\n\n'--stringtable-input'\nAssume the input file is a NeXTstep/GNUstep localized resource file\nin '.strings' syntax, not in PO file syntax.\n\n\n'--color'\n'--color=WHEN'\nSpecify whether or when to use colors and other text attributes.\nSee *note The --color option:: for details.\n\n'--style=STYLEFILE'\nSpecify the CSS style rule file to use for '--color'.  See *note\nThe --style option:: for details.\n\n'--force-po'\nAlways write an output file even if it contains no message.\n\n'--indent'\nWrite the .po file using indented style.\n\n'--keep-header'\nKeep the header entry, i.e. the message with 'msgid \"\"',\nunmodified, instead of filtering it.  By default, the header entry\nis subject to filtering like any other message.\n\n'--no-location'\nDo not write '#: FILENAME:LINE' lines.\n\n'-n'\n'--add-location=TYPE'\nGenerate '#: FILENAME:LINE' lines (default).\n\nThe optional TYPE can be either 'full', 'file', or 'never'.  If it\nis not given or 'full', it generates the lines with both file name\nand line number.  If it is 'file', the line number part is omitted.\nIf it is 'never', it completely suppresses the lines (same as\n'--no-location').\n\n'--strict'\nWrite out a strict Uniforum conforming PO file.  Note that this\nUniforum format should be avoided because it doesn't support the\nGNU extensions.\n\n'-p'\n'--properties-output'\nWrite out a Java ResourceBundle in Java '.properties' syntax.  Note\nthat this file format doesn't support plural forms and silently\ndrops obsolete messages.\n\n'--stringtable-output'\nWrite out a NeXTstep/GNUstep localized resource file in '.strings'\nsyntax.  Note that this file format doesn't support plural forms.\n\n'-w NUMBER'\n'--width=NUMBER'\nSet the output page width.  Long strings in the output files will\nbe split across multiple lines in order to ensure that each line's\nwidth (= number of screen columns) is less or equal to the given\nNUMBER.\n\n'--no-wrap'\nDo not break long message lines.  Message lines whose width exceeds\nthe output page width will not be split into several lines.  Only\nfile reference lines which are wider than the output page width\nwill be split.\n\n'-s'\n'--sort-output'\nGenerate sorted output.  Note that using this option makes it much\nharder for the translator to understand each message's context.\n\n'-F'\n'--sort-by-file'\nSort output by file location.\n\n\n'-h'\n'--help'\nDisplay this help and exit.\n\n'-V'\n'--version'\nOutput version information and exit.\n\n\nTo convert German translations to Swiss orthography (in an UTF-8\nlocale):\n\nmsgconv -t UTF-8 de.po | msgfilter sed -e 's/ss/ss/g'\n\nTo convert Serbian translations in Cyrillic script to Latin script:\n\nmsgfilter recode-sr-latin < sr.po\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}