jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: GNU gettext utilities: 9. Manipulating PO Files jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:
[ << ][ >> ]           [Top][Contents][Index][ ? ]
jpayne@68: jpayne@68:
jpayne@68: jpayne@68: jpayne@68:

9. Manipulating PO Files

jpayne@68: jpayne@68:

Sometimes it is necessary to manipulate PO files in a way that is better jpayne@68: performed automatically than by hand. GNU gettext includes a jpayne@68: complete set of tools for this purpose. jpayne@68:

jpayne@68: jpayne@68:

When merging two packages into a single package, the resulting POT file jpayne@68: will be the concatenation of the two packages' POT files. Thus the jpayne@68: maintainer must concatenate the two existing package translations into jpayne@68: a single translation catalog, for each language. This is best performed jpayne@68: using ‘msgcat’. It is then the translators' duty to deal with any jpayne@68: possible conflicts that arose during the merge. jpayne@68:

jpayne@68: jpayne@68:

When a translator takes over the translation job from another translator, jpayne@68: but she uses a different character encoding in her locale, she will jpayne@68: convert the catalog to her character encoding. This is best done through jpayne@68: the ‘msgconv’ program. jpayne@68:

jpayne@68:

When a maintainer takes a source file with tagged messages from another jpayne@68: package, he should also take the existing translations for this source jpayne@68: file (and not let the translators do the same job twice). One way to do jpayne@68: this is through ‘msggrep’, another is to create a POT file for jpayne@68: that source file and use ‘msgmerge’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

When a translator wants to adjust some translation catalog for a special jpayne@68: dialect or orthography — for example, German as written in Switzerland jpayne@68: versus German as written in Germany — she needs to apply some text jpayne@68: processing to every message in the catalog. The tool for doing this is jpayne@68: ‘msgfilter’. jpayne@68:

jpayne@68:

Another use of msgfilter is to produce approximately the POT file for jpayne@68: which a given PO file was made. This can be done through a filter command jpayne@68: like ‘msgfilter sed -e d | sed -e '/^# /d'’. Note that the original jpayne@68: POT file may have had different comments and different plural message counts, jpayne@68: that's why it's better to use the original POT file if available. jpayne@68:

jpayne@68: jpayne@68:

When a translator wants to check her translations, for example according jpayne@68: to orthography rules or using a non-interactive spell checker, she can do jpayne@68: so using the ‘msgexec’ program. jpayne@68:

jpayne@68: jpayne@68:

When third party tools create PO or POT files, sometimes duplicates cannot jpayne@68: be avoided. But the GNU gettext tools give an error when they jpayne@68: encounter duplicate msgids in the same file and in the same domain. jpayne@68: To merge duplicates, the ‘msguniq’ program can be used. jpayne@68:

jpayne@68:

msgcomm’ is a more general tool for keeping or throwing away jpayne@68: duplicates, occurring in different files. jpayne@68:

jpayne@68:

msgcmp’ can be used to check whether a translation catalog is jpayne@68: completely translated. jpayne@68:

jpayne@68: jpayne@68:

msgattrib’ can be used to select and extract only the fuzzy jpayne@68: or untranslated messages of a translation catalog. jpayne@68:

jpayne@68:

msgen’ is useful as a first step for preparing English translation jpayne@68: catalogs. It copies each message's msgid to its msgstr. jpayne@68:

jpayne@68:

Finally, for those applications where all these various programs are not jpayne@68: sufficient, a library ‘libgettextpo’ is provided that can be used to jpayne@68: write other specialized programs that process PO files. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.1 Invoking the msgcat Program

jpayne@68: jpayne@68: jpayne@68:
 
msgcat [option] [inputfile]...
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

The msgcat program concatenates and merges the specified PO files. jpayne@68: It finds messages which are common to two or more of the specified PO files. jpayne@68: By using the --more-than option, greater commonality may be requested jpayne@68: before messages are printed. Conversely, the --less-than option may be jpayne@68: used to specify less commonality before messages are printed (i.e. jpayne@68: ‘--less-than=2’ will only print the unique messages). Translations, jpayne@68: comments, extracted comments, and file positions will be cumulated, except that jpayne@68: if --use-first is specified, they will be taken from the first PO file jpayne@68: to define them. jpayne@68:

jpayne@68:

To concatenate POT files, better use xgettext, not msgcat, jpayne@68: because msgcat would choke on the undefined charsets in the specified jpayne@68: POT files. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.1.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input files. jpayne@68:

jpayne@68:
jpayne@68:
-f file
jpayne@68:
--files-from=file
jpayne@68:
jpayne@68: jpayne@68:

Read the names of the input files from file instead of getting jpayne@68: them from the command line. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If inputfile is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.1.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.1.3 Message selection

jpayne@68: jpayne@68:
jpayne@68:
-< number
jpayne@68:
--less-than=number
jpayne@68:
jpayne@68: jpayne@68:

Print messages with less than number definitions, defaults to infinite jpayne@68: if not set. jpayne@68:

jpayne@68:
jpayne@68:
-> number
jpayne@68:
--more-than=number
jpayne@68:
jpayne@68: jpayne@68:

Print messages with more than number definitions, defaults to 0 if not jpayne@68: set. jpayne@68:

jpayne@68:
jpayne@68:
-u
jpayne@68:
--unique
jpayne@68:
jpayne@68: jpayne@68:

Shorthand for ‘--less-than=2’. Requests that only unique messages be jpayne@68: printed. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.1.4 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input files are Java ResourceBundles in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input files are NeXTstep/GNUstep localized resource files in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.1.5 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
-t
jpayne@68:
--to-code=name
jpayne@68:
jpayne@68: jpayne@68:

Specify encoding for output. jpayne@68:

jpayne@68:
jpayne@68:
--use-first
jpayne@68:
jpayne@68:

Use first available translation for each message. Don't merge several jpayne@68: translations into one. jpayne@68:

jpayne@68:
jpayne@68:
--lang=catalogname
jpayne@68:
jpayne@68:

Specify the ‘Language’ field to be used in the header entry. See jpayne@68: Filling in the Header Entry for the meaning of this field. Note: The jpayne@68: ‘Language-Team’ and ‘Plural-Forms’ fields are left unchanged. jpayne@68:

jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--indent
jpayne@68:
jpayne@68: jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68: jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.1.6 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.2 Invoking the msgconv Program

jpayne@68: jpayne@68: jpayne@68:
 
msgconv [option] [inputfile]
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msgconv program converts a translation catalog to a different jpayne@68: character encoding. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.2.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input PO file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If no inputfile is given or if it is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.2.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.2.3 Conversion target

jpayne@68: jpayne@68:
jpayne@68:
-t
jpayne@68:
--to-code=name
jpayne@68:
jpayne@68: jpayne@68:

Specify encoding for output. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The default encoding is the current locale's encoding. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.2.4 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.2.5 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--indent
jpayne@68:
jpayne@68: jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.2.6 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.3 Invoking the msggrep Program

jpayne@68: jpayne@68: jpayne@68:
 
msggrep [option] [inputfile]
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msggrep program extracts all messages of a translation catalog jpayne@68: that match a given pattern or belong to some given source files. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.3.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input PO file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If no inputfile is given or if it is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.3.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.3.3 Message selection

jpayne@68: jpayne@68:
 
  [-N sourcefile]... [-M domainname]...
jpayne@68:   [-J msgctxt-pattern] [-K msgid-pattern] [-T msgstr-pattern]
jpayne@68:   [-C comment-pattern]
jpayne@68: 
jpayne@68: jpayne@68:

A message is selected if jpayne@68:

jpayne@68: jpayne@68:

When more than one selection criterion is specified, the set of selected jpayne@68: messages is the union of the selected messages of each criterion. jpayne@68:

jpayne@68:

msgctxt-pattern or msgid-pattern or msgstr-pattern syntax: jpayne@68:

 
  [-E | -F] [-e pattern | -f file]...
jpayne@68: 
jpayne@68:

patterns are basic regular expressions by default, or extended regular jpayne@68: expressions if -E is given, or fixed strings if -F is given. jpayne@68:

jpayne@68:
jpayne@68:
-N sourcefile
jpayne@68:
--location=sourcefile
jpayne@68:
jpayne@68: jpayne@68:

Select messages extracted from sourcefile. sourcefile can be jpayne@68: either a literal file name or a wildcard pattern. jpayne@68:

jpayne@68:
jpayne@68:
-M domainname
jpayne@68:
--domain=domainname
jpayne@68:
jpayne@68: jpayne@68:

Select messages belonging to domain domainname. jpayne@68:

jpayne@68:
jpayne@68:
-J
jpayne@68:
--msgctxt
jpayne@68:
jpayne@68: jpayne@68:

Start of patterns for the msgctxt. jpayne@68:

jpayne@68:
jpayne@68:
-K
jpayne@68:
--msgid
jpayne@68:
jpayne@68: jpayne@68:

Start of patterns for the msgid. jpayne@68:

jpayne@68:
jpayne@68:
-T
jpayne@68:
--msgstr
jpayne@68:
jpayne@68: jpayne@68:

Start of patterns for the msgstr. jpayne@68:

jpayne@68:
jpayne@68:
-C
jpayne@68:
--comment
jpayne@68:
jpayne@68: jpayne@68:

Start of patterns for the translator's comment. jpayne@68:

jpayne@68:
jpayne@68:
-X
jpayne@68:
--extracted-comment
jpayne@68:
jpayne@68: jpayne@68:

Start of patterns for the extracted comments. jpayne@68:

jpayne@68:
jpayne@68:
-E
jpayne@68:
--extended-regexp
jpayne@68:
jpayne@68: jpayne@68:

Specify that pattern is an extended regular expression. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--fixed-strings
jpayne@68:
jpayne@68: jpayne@68:

Specify that pattern is a set of newline-separated strings. jpayne@68:

jpayne@68:
jpayne@68:
-e pattern
jpayne@68:
--regexp=pattern
jpayne@68:
jpayne@68: jpayne@68:

Use pattern as a regular expression. jpayne@68:

jpayne@68:
jpayne@68:
-f file
jpayne@68:
--file=file
jpayne@68:
jpayne@68: jpayne@68:

Obtain pattern from file. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--ignore-case
jpayne@68:
jpayne@68: jpayne@68:

Ignore case distinctions. jpayne@68:

jpayne@68:
jpayne@68:
-v
jpayne@68:
--invert-match
jpayne@68:
jpayne@68: jpayne@68:

Output only the messages that do not match any selection criterion, instead jpayne@68: of the messages that match a selection criterion. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.3.4 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.3.5 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
--indent
jpayne@68:
jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
--sort-output
jpayne@68:
jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.3.6 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.3.7 Examples

jpayne@68: jpayne@68:

To extract the messages that come from the source files jpayne@68: gnulib-lib/error.c and gnulib-lib/getopt.c: jpayne@68:

jpayne@68:
 
msggrep -N gnulib-lib/error.c -N gnulib-lib/getopt.c input.po
jpayne@68: 
jpayne@68: jpayne@68:

To extract the messages that contain the string “Please specify” in the jpayne@68: original string: jpayne@68:

jpayne@68:
 
msggrep --msgid -F -e 'Please specify' input.po
jpayne@68: 
jpayne@68: jpayne@68:

To extract the messages that have a context specifier of either “Menu>File” jpayne@68: or “Menu>Edit” or a submenu of them: jpayne@68:

jpayne@68:
 
msggrep --msgctxt -E -e '^Menu>(File|Edit)' input.po
jpayne@68: 
jpayne@68: jpayne@68:

To extract the messages whose translation contains one of the strings in the jpayne@68: file wordlist.txt: jpayne@68:

jpayne@68:
 
msggrep --msgstr -F -f wordlist.txt input.po
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.4 Invoking the msgfilter Program

jpayne@68: jpayne@68: jpayne@68:
 
msgfilter [option] filter [filter-option]
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msgfilter program applies a filter to all translations of a jpayne@68: translation catalog. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

During each filter invocation, the environment variable jpayne@68: MSGFILTER_MSGID is bound to the message's msgid, and the environment jpayne@68: variable MSGFILTER_LOCATION is bound to the location in the PO file jpayne@68: of the message. If the message has a context, the environment variable jpayne@68: MSGFILTER_MSGCTXT is bound to the message's msgctxt, otherwise it is jpayne@68: unbound. If the message has a plural form, environment variable jpayne@68: MSGFILTER_MSGID_PLURAL is bound to the message's msgid_plural and jpayne@68: MSGFILTER_PLURAL_FORM is bound to the order number of the plural jpayne@68: actually processed (starting with 0), otherwise both are unbound. jpayne@68: If the message has a previous msgid (added by msgmerge), jpayne@68: environment variable MSGFILTER_PREV_MSGCTXT is bound to the jpayne@68: message's previous msgctxt, MSGFILTER_PREV_MSGID is bound to jpayne@68: the previous msgid, and MSGFILTER_PREV_MSGID_PLURAL is bound to jpayne@68: the previous msgid_plural. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.4.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
-i inputfile
jpayne@68:
--input=inputfile
jpayne@68:
jpayne@68: jpayne@68:

Input PO file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If no inputfile is given or if it is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.4.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.4.3 The filter

jpayne@68: jpayne@68:

The filter can be any program that reads a translation from standard jpayne@68: input and writes a modified translation to standard output. A frequently jpayne@68: used filter is ‘sed’. A few particular built-in filters are also jpayne@68: recognized. jpayne@68:

jpayne@68:
jpayne@68:
--newline
jpayne@68:
jpayne@68:

Add newline at the end of each input line and also strip the ending jpayne@68: newline from the output line. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68:

Note: If the filter is not a built-in filter, you have to care about encodings: jpayne@68: It is your responsibility to ensure that the filter can cope jpayne@68: with input encoded in the translation catalog's encoding. If the jpayne@68: filter wants input in a particular encoding, you can in a first step jpayne@68: convert the translation catalog to that encoding using the ‘msgconv’ jpayne@68: program, before invoking ‘msgfilter’. If the filter wants input jpayne@68: in the locale's encoding, but you want to avoid the locale's encoding, then jpayne@68: you can first convert the translation catalog to UTF-8 using the jpayne@68: ‘msgconv’ program and then make ‘msgfilter’ work in an UTF-8 jpayne@68: locale, by using the LC_ALL environment variable. jpayne@68:

jpayne@68: jpayne@68:

Note: Most translations in a translation catalog don't end with a jpayne@68: newline character. For this reason, unless the --newline jpayne@68: option is used, it is important that the filter recognizes its jpayne@68: last input line even if it ends without a newline, and that it doesn't jpayne@68: add an undesired trailing newline at the end. The ‘sed’ program on jpayne@68: some platforms is known to ignore the last line of input if it is not jpayne@68: terminated with a newline. You can use GNU sed instead; it does jpayne@68: not have this limitation. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.4.4 Useful filter-options when the filter is ‘sed

jpayne@68: jpayne@68:
jpayne@68:
-e script
jpayne@68:
--expression=script
jpayne@68:
jpayne@68: jpayne@68:

Add script to the commands to be executed. jpayne@68:

jpayne@68:
jpayne@68:
-f scriptfile
jpayne@68:
--file=scriptfile
jpayne@68:
jpayne@68: jpayne@68:

Add the contents of scriptfile to the commands to be executed. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--quiet
jpayne@68:
--silent
jpayne@68:
jpayne@68: jpayne@68: jpayne@68:

Suppress automatic printing of pattern space. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.4.5 Built-in filters

jpayne@68: jpayne@68:

The filter ‘recode-sr-latin’ is recognized as a built-in filter. jpayne@68: The command ‘recode-sr-latin’ converts Serbian text, written in the jpayne@68: Cyrillic script, to the Latin script. jpayne@68: The command ‘msgfilter recode-sr-latin’ applies this conversion to the jpayne@68: translations of a PO file. Thus, it can be used to convert an ‘sr.po’ jpayne@68: file to an ‘sr@latin.po’ file. jpayne@68:

jpayne@68: jpayne@68:

The filter ‘quot’ is recognized as a built-in filter. jpayne@68: The command ‘msgfilter quot’ converts any quotations surrounded jpayne@68: by a pair of ‘"’, ‘'’, and ‘`’. jpayne@68:

jpayne@68: jpayne@68:

The filter ‘boldquot’ is recognized as a built-in filter. jpayne@68: The command ‘msgfilter boldquot’ converts any quotations jpayne@68: surrounded by a pair of ‘"’, ‘'’, and ‘`’, also adding the jpayne@68: VT100 escape sequences to the text to decorate it as bold. jpayne@68:

jpayne@68:

The use of built-in filters is not sensitive to the current locale's encoding. jpayne@68: Moreover, when used with a built-in filter, ‘msgfilter’ can automatically jpayne@68: convert the message catalog to the UTF-8 encoding when needed. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.4.6 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.4.7 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
--indent
jpayne@68:
jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--keep-header
jpayne@68:
jpayne@68:

Keep the header entry, i.e. the message with ‘msgid ""’, unmodified, jpayne@68: instead of filtering it. By default, the header entry is subject to jpayne@68: filtering like any other message. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.4.8 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.4.9 Examples

jpayne@68: jpayne@68:

To convert German translations to Swiss orthography (in an UTF-8 locale): jpayne@68:

jpayne@68:
 
msgconv -t UTF-8 de.po | msgfilter sed -e 's/ß/ss/g'
jpayne@68: 
jpayne@68: jpayne@68:

To convert Serbian translations in Cyrillic script to Latin script: jpayne@68:

jpayne@68:
 
msgfilter recode-sr-latin < sr.po
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.5 Invoking the msguniq Program

jpayne@68: jpayne@68: jpayne@68:
 
msguniq [option] [inputfile]
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

The msguniq program unifies duplicate translations in a translation jpayne@68: catalog. It finds duplicate translations of the same message ID. Such jpayne@68: duplicates are invalid input for other programs like msgfmt, jpayne@68: msgmerge or msgcat. By default, duplicates are merged jpayne@68: together. When using the ‘--repeated’ option, only duplicates are jpayne@68: output, and all other messages are discarded. Comments and extracted jpayne@68: comments will be cumulated, except that if ‘--use-first’ is jpayne@68: specified, they will be taken from the first translation. File positions jpayne@68: will be cumulated. When using the ‘--unique’ option, duplicates are jpayne@68: discarded. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.5.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input PO file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If no inputfile is given or if it is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.5.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.5.3 Message selection

jpayne@68: jpayne@68:
jpayne@68:
-d
jpayne@68:
--repeated
jpayne@68:
jpayne@68: jpayne@68:

Print only duplicates. jpayne@68:

jpayne@68:
jpayne@68:
-u
jpayne@68:
--unique
jpayne@68:
jpayne@68: jpayne@68:

Print only unique messages, discard duplicates. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.5.4 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.5.5 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
-t
jpayne@68:
--to-code=name
jpayne@68:
jpayne@68: jpayne@68:

Specify encoding for output. jpayne@68:

jpayne@68:
jpayne@68:
--use-first
jpayne@68:
jpayne@68:

Use first available translation for each message. Don't merge several jpayne@68: translations into one. jpayne@68:

jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--indent
jpayne@68:
jpayne@68: jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68: jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.5.6 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.6 Invoking the msgcomm Program

jpayne@68: jpayne@68: jpayne@68:
 
msgcomm [option] [inputfile]...
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msgcomm program finds messages which are common to two or more jpayne@68: of the specified PO files. jpayne@68: By using the --more-than option, greater commonality may be requested jpayne@68: before messages are printed. Conversely, the --less-than option may be jpayne@68: used to specify less commonality before messages are printed (i.e. jpayne@68: ‘--less-than=2’ will only print the unique messages). Translations, jpayne@68: comments and extracted comments will be preserved, but only from the first jpayne@68: PO file to define them. File positions from all PO files will be jpayne@68: cumulated. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.6.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input files. jpayne@68:

jpayne@68:
jpayne@68:
-f file
jpayne@68:
--files-from=file
jpayne@68:
jpayne@68: jpayne@68:

Read the names of the input files from file instead of getting jpayne@68: them from the command line. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If inputfile is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.6.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.6.3 Message selection

jpayne@68: jpayne@68:
jpayne@68:
-< number
jpayne@68:
--less-than=number
jpayne@68:
jpayne@68: jpayne@68:

Print messages with less than number definitions, defaults to infinite jpayne@68: if not set. jpayne@68:

jpayne@68:
jpayne@68:
-> number
jpayne@68:
--more-than=number
jpayne@68:
jpayne@68: jpayne@68:

Print messages with more than number definitions, defaults to 1 if not jpayne@68: set. jpayne@68:

jpayne@68:
jpayne@68:
-u
jpayne@68:
--unique
jpayne@68:
jpayne@68: jpayne@68:

Shorthand for ‘--less-than=2’. Requests that only unique messages be jpayne@68: printed. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.6.4 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input files are Java ResourceBundles in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input files are NeXTstep/GNUstep localized resource files in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.6.5 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--indent
jpayne@68:
jpayne@68: jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68: jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
--omit-header
jpayne@68:
jpayne@68:

Don't write header with ‘msgid ""’ entry. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.6.6 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.7 Invoking the msgcmp Program

jpayne@68: jpayne@68: jpayne@68:
 
msgcmp [option] def.po ref.pot
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msgcmp program compares two Uniforum style .po files to check that jpayne@68: both contain the same set of msgid strings. The def.po file is an jpayne@68: existing PO file with the translations. The ref.pot file is the last jpayne@68: created PO file, or a PO Template file (generally created by xgettext). jpayne@68: This is useful for checking that you have translated each and every message jpayne@68: in your program. Where an exact match cannot be found, fuzzy matching is jpayne@68: used to produce better diagnostics. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.7.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
def.po
jpayne@68:

Translations. jpayne@68:

jpayne@68:
jpayne@68:
ref.pot
jpayne@68:

References to the sources. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.7.2 Operation modifiers

jpayne@68: jpayne@68:
jpayne@68:
-m
jpayne@68:
--multi-domain
jpayne@68:
jpayne@68: jpayne@68:

Apply ref.pot to each of the domains in def.po. jpayne@68:

jpayne@68:
jpayne@68:
-N
jpayne@68:
--no-fuzzy-matching
jpayne@68:
jpayne@68: jpayne@68:

Do not use fuzzy matching when an exact match is not found. This may speed jpayne@68: up the operation considerably. jpayne@68:

jpayne@68:
jpayne@68:
--use-fuzzy
jpayne@68:
jpayne@68:

Consider fuzzy messages in the def.po file like translated messages. jpayne@68: Note that using this option is usually wrong, because fuzzy messages are jpayne@68: exactly those which have not been validated by a human translator. jpayne@68:

jpayne@68:
jpayne@68:
--use-untranslated
jpayne@68:
jpayne@68:

Consider untranslated messages in the def.po file like translated jpayne@68: messages. Note that using this option is usually wrong. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.7.3 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input files are Java ResourceBundles in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input files are NeXTstep/GNUstep localized resource files in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.7.4 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.8 Invoking the msgattrib Program

jpayne@68: jpayne@68: jpayne@68:
 
msgattrib [option] [inputfile]
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

The msgattrib program filters the messages of a translation catalog jpayne@68: according to their attributes, and manipulates the attributes. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.8.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input PO file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If no inputfile is given or if it is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.8.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.8.3 Message selection

jpayne@68: jpayne@68:
jpayne@68:
--translated
jpayne@68:
jpayne@68:

Keep translated messages, remove untranslated messages. jpayne@68:

jpayne@68:
jpayne@68:
--untranslated
jpayne@68:
jpayne@68:

Keep untranslated messages, remove translated messages. jpayne@68:

jpayne@68:
jpayne@68:
--no-fuzzy
jpayne@68:
jpayne@68:

Remove jpayne@68: ‘fuzzy’ jpayne@68: marked messages. jpayne@68:

jpayne@68:
jpayne@68:
--only-fuzzy
jpayne@68:
jpayne@68:

Keep jpayne@68: ‘fuzzy’ jpayne@68: marked messages, remove all other messages. jpayne@68:

jpayne@68:
jpayne@68:
--no-obsolete
jpayne@68:
jpayne@68:

Remove obsolete #~ messages. jpayne@68:

jpayne@68:
jpayne@68:
--only-obsolete
jpayne@68:
jpayne@68:

Keep obsolete #~ messages, remove all other messages. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.8.4 Attribute manipulation

jpayne@68: jpayne@68:

Attributes are modified after the message selection/removal has been jpayne@68: performed. If the ‘--only-file’ or ‘--ignore-file’ option is jpayne@68: specified, the attribute modification is applied only to those messages jpayne@68: that are listed in the only-file and not listed in the jpayne@68: ignore-file. jpayne@68:

jpayne@68:
jpayne@68:
--set-fuzzy
jpayne@68:
jpayne@68:

Set all messages jpayne@68: ‘fuzzy’. jpayne@68:

jpayne@68:
jpayne@68:
--clear-fuzzy
jpayne@68:
jpayne@68:

Set all messages jpayne@68: non-‘fuzzy’. jpayne@68:

jpayne@68:
jpayne@68:
--set-obsolete
jpayne@68:
jpayne@68:

Set all messages obsolete. jpayne@68:

jpayne@68:
jpayne@68:
--clear-obsolete
jpayne@68:
jpayne@68:

Set all messages non-obsolete. jpayne@68:

jpayne@68:
jpayne@68:
--previous
jpayne@68:
jpayne@68:

When setting jpayne@68: ‘fuzzy’ jpayne@68: mark, keep “previous msgid” of translated messages. jpayne@68:

jpayne@68:
jpayne@68:
--clear-previous
jpayne@68:
jpayne@68:

Remove the “previous msgid” (‘#|’) comments from all messages. jpayne@68:

jpayne@68:
jpayne@68:
--empty
jpayne@68:
jpayne@68:

When removing jpayne@68: ‘fuzzy’ jpayne@68: mark, also set msgstr empty. jpayne@68:

jpayne@68:
jpayne@68:
--only-file=file
jpayne@68:
jpayne@68:

Limit the attribute changes to entries that are listed in file. jpayne@68: file should be a PO or POT file. jpayne@68:

jpayne@68:
jpayne@68:
--ignore-file=file
jpayne@68:
jpayne@68:

Limit the attribute changes to entries that are not listed in file. jpayne@68: file should be a PO or POT file. jpayne@68:

jpayne@68:
jpayne@68:
--fuzzy
jpayne@68:
jpayne@68:

Synonym for ‘--only-fuzzy --clear-fuzzy’: It keeps only the fuzzy jpayne@68: messages and removes their jpayne@68: ‘fuzzy’ jpayne@68: mark. jpayne@68:

jpayne@68:
jpayne@68:
--obsolete
jpayne@68:
jpayne@68:

Synonym for ‘--only-obsolete --clear-obsolete’: It keeps only the jpayne@68: obsolete messages and makes them non-obsolete. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.8.5 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.8.6 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--indent
jpayne@68:
jpayne@68: jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68: jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.8.7 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.9 Invoking the msgen Program

jpayne@68: jpayne@68: jpayne@68:
 
msgen [option] inputfile
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msgen program creates an English translation catalog. The jpayne@68: input file is the last created English PO file, or a PO Template file jpayne@68: (generally created by xgettext). Untranslated entries are assigned a jpayne@68: translation that is identical to the msgid. jpayne@68:

jpayne@68:

Note: ‘msginit --no-translator --locale=en’ performs a very similar jpayne@68: task. The main difference is that msginit cares specially about jpayne@68: the header entry, whereas msgen doesn't. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.9.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
inputfile
jpayne@68:

Input PO or POT file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If inputfile is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.9.2 Output file location

jpayne@68: jpayne@68:
jpayne@68:
-o file
jpayne@68:
--output-file=file
jpayne@68:
jpayne@68: jpayne@68:

Write output to specified file. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

The results are written to standard output if no output file is specified jpayne@68: or if it is ‘-’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.9.3 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.9.4 Output details

jpayne@68: jpayne@68: jpayne@68:
jpayne@68:
--lang=catalogname
jpayne@68:
jpayne@68:

Specify the ‘Language’ field to be used in the header entry. See jpayne@68: Filling in the Header Entry for the meaning of this field. Note: The jpayne@68: ‘Language-Team’ and ‘Plural-Forms’ fields are not set by this jpayne@68: option. jpayne@68:

jpayne@68:
jpayne@68:
--color
jpayne@68:
--color=when
jpayne@68:
jpayne@68:

Specify whether or when to use colors and other text attributes. jpayne@68: See The --color option for details. jpayne@68:

jpayne@68:
jpayne@68:
--style=style_file
jpayne@68:
jpayne@68:

Specify the CSS style rule file to use for --color. jpayne@68: See The --style option for details. jpayne@68:

jpayne@68:
jpayne@68:
--force-po
jpayne@68:
jpayne@68:

Always write an output file even if it contains no message. jpayne@68:

jpayne@68:
jpayne@68:
-i
jpayne@68:
--indent
jpayne@68:
jpayne@68: jpayne@68:

Write the .po file using indented style. jpayne@68:

jpayne@68:
jpayne@68:
--no-location
jpayne@68:
jpayne@68:

Do not write ‘#: filename:line’ lines. jpayne@68:

jpayne@68:
jpayne@68:
-n
jpayne@68:
--add-location=type
jpayne@68:
jpayne@68:

Generate ‘#: filename:line’ lines (default). jpayne@68:

jpayne@68:

The optional type can be either ‘full’, ‘file’, or jpayne@68: ‘never’. If it is not given or ‘full’, it generates the jpayne@68: lines with both file name and line number. If it is ‘file’, the jpayne@68: line number part is omitted. If it is ‘never’, it completely jpayne@68: suppresses the lines (same as --no-location). jpayne@68:

jpayne@68:
jpayne@68:
--strict
jpayne@68:
jpayne@68:

Write out a strict Uniforum conforming PO file. Note that this jpayne@68: Uniforum format should be avoided because it doesn't support the jpayne@68: GNU extensions. jpayne@68:

jpayne@68:
jpayne@68:
-p
jpayne@68:
--properties-output
jpayne@68:
jpayne@68: jpayne@68:

Write out a Java ResourceBundle in Java .properties syntax. Note jpayne@68: that this file format doesn't support plural forms and silently drops jpayne@68: obsolete messages. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-output
jpayne@68:
jpayne@68:

Write out a NeXTstep/GNUstep localized resource file in .strings syntax. jpayne@68: Note that this file format doesn't support plural forms. jpayne@68:

jpayne@68:
jpayne@68:
-w number
jpayne@68:
--width=number
jpayne@68:
jpayne@68: jpayne@68:

Set the output page width. Long strings in the output files will be jpayne@68: split across multiple lines in order to ensure that each line's width jpayne@68: (= number of screen columns) is less or equal to the given number. jpayne@68:

jpayne@68:
jpayne@68:
--no-wrap
jpayne@68:
jpayne@68:

Do not break long message lines. Message lines whose width exceeds the jpayne@68: output page width will not be split into several lines. Only file reference jpayne@68: lines which are wider than the output page width will be split. jpayne@68:

jpayne@68:
jpayne@68:
-s
jpayne@68:
--sort-output
jpayne@68:
jpayne@68: jpayne@68:

Generate sorted output. Note that using this option makes it much harder jpayne@68: for the translator to understand each message's context. jpayne@68:

jpayne@68:
jpayne@68:
-F
jpayne@68:
--sort-by-file
jpayne@68:
jpayne@68: jpayne@68:

Sort output by file location. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.9.5 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.10 Invoking the msgexec Program

jpayne@68: jpayne@68: jpayne@68:
 
msgexec [option] command [command-option]
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68:

The msgexec program applies a command to all translations of a jpayne@68: translation catalog. jpayne@68: The command can be any program that reads a translation from standard jpayne@68: input. It is invoked once for each translation. Its output becomes jpayne@68: msgexec's output. msgexec's return code is the maximum return code jpayne@68: across all invocations. jpayne@68:

jpayne@68: jpayne@68:

A special builtin command called ‘0’ outputs the translation, followed jpayne@68: by a null byte. The output of ‘msgexec 0’ is suitable as input for jpayne@68: ‘xargs -0’. jpayne@68:

jpayne@68:
jpayne@68:
--newline
jpayne@68:
jpayne@68:

Add newline at the end of each input line. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

During each command invocation, the environment variable jpayne@68: MSGEXEC_MSGID is bound to the message's msgid, and the environment jpayne@68: variable MSGEXEC_LOCATION is bound to the location in the PO file jpayne@68: of the message. If the message has a context, the environment variable jpayne@68: MSGEXEC_MSGCTXT is bound to the message's msgctxt, otherwise it is jpayne@68: unbound. If the message has a plural form, environment variable jpayne@68: MSGEXEC_MSGID_PLURAL is bound to the message's msgid_plural and jpayne@68: MSGEXEC_PLURAL_FORM is bound to the order number of the plural jpayne@68: actually processed (starting with 0), otherwise both are unbound. jpayne@68: If the message has a previous msgid (added by msgmerge), jpayne@68: environment variable MSGEXEC_PREV_MSGCTXT is bound to the jpayne@68: message's previous msgctxt, MSGEXEC_PREV_MSGID is bound to jpayne@68: the previous msgid, and MSGEXEC_PREV_MSGID_PLURAL is bound to jpayne@68: the previous msgid_plural. jpayne@68:

jpayne@68: jpayne@68:

Note: It is your responsibility to ensure that the command can cope jpayne@68: with input encoded in the translation catalog's encoding. If the jpayne@68: command wants input in a particular encoding, you can in a first step jpayne@68: convert the translation catalog to that encoding using the ‘msgconv’ jpayne@68: program, before invoking ‘msgexec’. If the command wants input jpayne@68: in the locale's encoding, but you want to avoid the locale's encoding, then jpayne@68: you can first convert the translation catalog to UTF-8 using the jpayne@68: ‘msgconv’ program and then make ‘msgexec’ work in an UTF-8 jpayne@68: locale, by using the LC_ALL environment variable. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.10.1 Input file location

jpayne@68: jpayne@68:
jpayne@68:
-i inputfile
jpayne@68:
--input=inputfile
jpayne@68:
jpayne@68: jpayne@68:

Input PO file. jpayne@68:

jpayne@68:
jpayne@68:
-D directory
jpayne@68:
--directory=directory
jpayne@68:
jpayne@68: jpayne@68:

Add directory to the list of directories. Source files are jpayne@68: searched relative to this list of directories. The resulting ‘.po’ jpayne@68: file will be written relative to the current directory, though. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68:

If no inputfile is given or if it is ‘-’, standard input is read. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

9.10.2 Input file syntax

jpayne@68: jpayne@68:
jpayne@68:
-P
jpayne@68:
--properties-input
jpayne@68:
jpayne@68: jpayne@68:

Assume the input file is a Java ResourceBundle in Java .properties jpayne@68: syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
--stringtable-input
jpayne@68:
jpayne@68:

Assume the input file is a NeXTstep/GNUstep localized resource file in jpayne@68: .strings syntax, not in PO file syntax. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.10.3 Informative output

jpayne@68: jpayne@68:
jpayne@68:
-h
jpayne@68:
--help
jpayne@68:
jpayne@68: jpayne@68:

Display this help and exit. jpayne@68:

jpayne@68:
jpayne@68:
-V
jpayne@68:
--version
jpayne@68:
jpayne@68: jpayne@68:

Output version information and exit. jpayne@68:

jpayne@68:
jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.11 Highlighting parts of PO files

jpayne@68: jpayne@68:

Translators are usually only interested in seeing the untranslated and jpayne@68: fuzzy messages of a PO file. Also, when a message is set fuzzy because jpayne@68: the msgid changed, they want to see the differences between the previous jpayne@68: msgid and the current one (especially if the msgid is long and only few jpayne@68: words in it have changed). Finally, it's always welcome to highlight the jpayne@68: different sections of a message in a PO file (comments, msgid, msgstr, etc.). jpayne@68:

jpayne@68:

Such highlighting is possible through the options ‘--color’ and jpayne@68: ‘--style’. They are supported by all the programs that produce jpayne@68: a PO file on standard output, such as msgcat, msgmerge, jpayne@68: and msgunfmt. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.11.1 The --color option

jpayne@68: jpayne@68:

The ‘--color=when’ option specifies under which conditions jpayne@68: colorized output should be generated. The when part can be one of jpayne@68: the following: jpayne@68:

jpayne@68:
jpayne@68:
always
jpayne@68:
yes
jpayne@68:

The output will be colorized. jpayne@68:

jpayne@68:
jpayne@68:
never
jpayne@68:
no
jpayne@68:

The output will not be colorized. jpayne@68:

jpayne@68:
jpayne@68:
auto
jpayne@68:
tty
jpayne@68:

The output will be colorized if the output device is a tty, i.e. when the jpayne@68: output goes directly to a text screen or terminal emulator window. jpayne@68:

jpayne@68:
jpayne@68:
html
jpayne@68:

The output will be colorized and be in HTML format. jpayne@68:

jpayne@68:
jpayne@68:
test
jpayne@68:

This is a special value, understood only by the msgcat program. It jpayne@68: is explained in the next section (The environment variable TERM). jpayne@68:

jpayne@68:
jpayne@68: jpayne@68:

--color’ is equivalent to ‘--color=yes’. The default is jpayne@68: ‘--color=auto’. jpayne@68:

jpayne@68:

Thus, a command like ‘msgcat vi.po’ will produce colorized output jpayne@68: when called by itself in a command window. Whereas in a pipe, such as jpayne@68: ‘msgcat vi.po | less -R’, it will not produce colorized output. To jpayne@68: get colorized output in this situation nevertheless, use the command jpayne@68: ‘msgcat --color vi.po | less -R’. jpayne@68:

jpayne@68:

The ‘--color=html’ option will produce output that can be viewed in jpayne@68: a browser. This can be useful, for example, for Indic languages, jpayne@68: because the renderic of Indic scripts in browsers is usually better than jpayne@68: in terminal emulators. jpayne@68:

jpayne@68:

Note that the output produced with the --color option is not jpayne@68: a valid PO file in itself. It contains additional terminal-specific escape jpayne@68: sequences or HTML tags. A PO file reader will give a syntax error when jpayne@68: confronted with such content. Except for the ‘--color=html’ case, jpayne@68: you therefore normally don't need to save output produced with the jpayne@68: --color option in a file. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.11.2 The environment variable TERM

jpayne@68: jpayne@68:

The environment variable TERM contains a identifier for the text jpayne@68: window's capabilities. You can get a detailed list of these cababilities jpayne@68: by using the ‘infocmp’ command, using ‘man 5 terminfo’ as a jpayne@68: reference. jpayne@68:

jpayne@68:

When producing text with embedded color directives, msgcat looks jpayne@68: at the TERM variable. Text windows today typically support at least jpayne@68: 8 colors. Often, however, the text window supports 16 or more colors, jpayne@68: even though the TERM variable is set to a identifier denoting only jpayne@68: 8 supported colors. It can be worth setting the TERM variable to jpayne@68: a different value in these cases: jpayne@68:

jpayne@68:
jpayne@68:
xterm
jpayne@68:

xterm is in most cases built with support for 16 colors. It can also jpayne@68: be built with support for 88 or 256 colors (but not both). You can try to jpayne@68: set TERM to either xterm-16color, xterm-88color, or jpayne@68: xterm-256color. jpayne@68:

jpayne@68:
jpayne@68:
rxvt
jpayne@68:

rxvt is often built with support for 16 colors. You can try to set jpayne@68: TERM to rxvt-16color. jpayne@68:

jpayne@68:
jpayne@68:
konsole
jpayne@68:

konsole too is often built with support for 16 colors. You can try to jpayne@68: set TERM to konsole-16color or xterm-16color. jpayne@68:

jpayne@68:
jpayne@68: jpayne@68:

After setting TERM, you can verify it by invoking jpayne@68: ‘msgcat --color=test’ and seeing whether the output looks like a jpayne@68: reasonable color map. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.11.3 The --style option

jpayne@68: jpayne@68:

The ‘--style=style_file’ option specifies the style file to use jpayne@68: when colorizing. It has an effect only when the --color option is jpayne@68: effective. jpayne@68:

jpayne@68: jpayne@68:

If the --style option is not specified, the environment variable jpayne@68: PO_STYLE is considered. It is meant to point to the user's jpayne@68: preferred style for PO files. jpayne@68:

jpayne@68:

The default style file is ‘$prefix/share/gettext/styles/po-default.css’, jpayne@68: where $prefix is the installation location. jpayne@68:

jpayne@68:

A few style files are predefined: jpayne@68:

jpayne@68:
po-vim.css
jpayne@68:

This style imitates the look used by vim 7. jpayne@68:

jpayne@68:
jpayne@68:
po-emacs-x.css
jpayne@68:

This style imitates the look used by GNU Emacs 21 and 22 in an X11 window. jpayne@68:

jpayne@68:
jpayne@68:
po-emacs-xterm.css
jpayne@68:
po-emacs-xterm16.css
jpayne@68:
po-emacs-xterm256.css
jpayne@68:

This style imitates the look used by GNU Emacs 22 in a terminal of type jpayne@68: ‘xterm’ (8 colors) or ‘xterm-16color’ (16 colors) or jpayne@68: ‘xterm-256color’ (256 colors), respectively. jpayne@68:

jpayne@68:
jpayne@68: jpayne@68:

You can use these styles without specifying a directory. They are actually jpayne@68: located in ‘$prefix/share/gettext/styles/’, where $prefix is the jpayne@68: installation location. jpayne@68:

jpayne@68:

You can also design your own styles. This is described in the next section. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.11.4 Style rules for PO files

jpayne@68: jpayne@68:

The same style file can be used for styling of a PO file, for terminal jpayne@68: output and for HTML output. It is written in CSS (Cascading Style Sheet) jpayne@68: syntax. See https://www.w3.org/TR/css2/cover.html for a formal jpayne@68: definition of CSS. Many HTML authoring tutorials also contain explanations jpayne@68: of CSS. jpayne@68:

jpayne@68:

In the case of HTML output, the style file is embedded in the HTML output. jpayne@68: In the case of text output, the style file is interpreted by the jpayne@68: msgcat program. This means, in particular, that when jpayne@68: @import is used with relative file names, the file names are jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

CSS rules are built up from selectors and declarations. The declarations jpayne@68: specify graphical properties; the selectors specify when they apply. jpayne@68:

jpayne@68:

In PO files, the following simple selectors (based on "CSS classes", see jpayne@68: the CSS2 spec, section 5.8.3) are supported. jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

These selectors can be combined to hierarchical selectors. For example, jpayne@68:

jpayne@68:
 
.msgstr .invalid-format-directive { color: red; }
jpayne@68: 
jpayne@68: jpayne@68:

will highlight the invalid format directives in the translated strings. jpayne@68:

jpayne@68:

In text mode, pseudo-classes (CSS2 spec, section 5.11) and pseudo-elements jpayne@68: (CSS2 spec, section 5.12) are not supported. jpayne@68:

jpayne@68:

The declarations in HTML mode are not limited; any graphical attribute jpayne@68: supported by the browsers can be used. jpayne@68:

jpayne@68:

The declarations in text mode are limited to the following properties. Other jpayne@68: properties will be silently ignored. jpayne@68:

jpayne@68:
jpayne@68:
color (CSS2 spec, section 14.1)
jpayne@68:
background-color (CSS2 spec, section 14.2.1)
jpayne@68:

These properties is supported. Colors will be adjusted to match the terminal's jpayne@68: capabilities. Note that many terminals support only 8 colors. jpayne@68:

jpayne@68:
jpayne@68:
font-weight (CSS2 spec, section 15.2.3)
jpayne@68:

This property is supported, but most terminals can only render two different jpayne@68: weights: normal and bold. Values >= 600 are rendered as jpayne@68: bold. jpayne@68:

jpayne@68:
jpayne@68:
font-style (CSS2 spec, section 15.2.3)
jpayne@68:

This property is supported. The values italic and oblique are jpayne@68: rendered the same way. jpayne@68:

jpayne@68:
jpayne@68:
text-decoration (CSS2 spec, section 16.3.1)
jpayne@68:

This property is supported, limited to the values none and jpayne@68: underline. jpayne@68:

jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.11.5 Customizing less for viewing PO files

jpayne@68: jpayne@68:

The ‘less’ program is a popular text file browser for use in a text jpayne@68: screen or terminal emulator. It also supports text with embedded escape jpayne@68: sequences for colors and text decorations. jpayne@68:

jpayne@68:

You can use less to view a PO file like this (assuming an UTF-8 jpayne@68: environment): jpayne@68:

jpayne@68:
 
msgcat --to-code=UTF-8 --color xyz.po | less -R
jpayne@68: 
jpayne@68: jpayne@68:

You can simplify this to this simple command: jpayne@68:

jpayne@68:
 
less xyz.po
jpayne@68: 
jpayne@68: jpayne@68:

after these three preparations: jpayne@68:

jpayne@68:
    jpayne@68:
  1. jpayne@68: Add the options ‘-R’ and ‘-f’ to the LESS environment jpayne@68: variable. In sh shells: jpayne@68:
     
    $ LESS="$LESS -R -f"
    jpayne@68: $ export LESS
    jpayne@68: 
    jpayne@68: jpayne@68:
  2. jpayne@68: If your system does not already have the ‘lessopen.sh’ and jpayne@68: ‘lessclose.sh’ scripts, create them and set the LESSOPEN and jpayne@68: LESSCLOSE environment variables, as indicated in the manual page jpayne@68: (‘man less’). jpayne@68: jpayne@68:
  3. jpayne@68: Add to ‘lessopen.sh’ a piece of script that recognizes PO files jpayne@68: through their file extension and invokes msgcat on them, producing jpayne@68: a temporary file. Like this: jpayne@68: jpayne@68:
     
    case "$1" in
    jpayne@68:   *.po)
    jpayne@68:     tmpfile=`mktemp "${TMPDIR-/tmp}/less.XXXXXX"`
    jpayne@68:     msgcat --to-code=UTF-8 --color "$1" > "$tmpfile"
    jpayne@68:     echo "$tmpfile"
    jpayne@68:     exit 0
    jpayne@68:     ;;
    jpayne@68: esac
    jpayne@68: 
    jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.12 Other tools for manipulating PO files

jpayne@68: jpayne@68:

The “Pology” package is a Free Software package for manipulating PO files. jpayne@68: It features, in particular: jpayne@68:

jpayne@68: jpayne@68: jpayne@68:

Its home page is at http://pology.nedohodnik.net/. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13 Writing your own programs that process PO files

jpayne@68: jpayne@68:

For the tasks for which a combination of ‘msgattrib’, ‘msgcat’ etc. jpayne@68: is not sufficient, a set of C functions is provided in a library, to make it jpayne@68: possible to process PO files in your own programs. When you use this library, jpayne@68: you don't need to write routines to parse the PO file; instead, you retrieve jpayne@68: a pointer in memory to each of messages contained in the PO file. Functions jpayne@68: for writing those memory structures to a file after working with them are jpayne@68: provided too. jpayne@68:

jpayne@68:

The functions are declared in the header file ‘<gettext-po.h>’, and are jpayne@68: defined in a library called ‘libgettextpo’. jpayne@68:

jpayne@68: jpayne@68:

The following example shows code how these functions can be used. Error jpayne@68: handling code is omitted, as its implementation is delegated to the user jpayne@68: provided functions. jpayne@68:

jpayne@68:
 
struct po_xerror_handler handler =
jpayne@68:   {
jpayne@68:     .xerror = …,
jpayne@68:     .xerror2 = …
jpayne@68:   };
jpayne@68: const char *filename = …;
jpayne@68: /* Read the file into memory.  */
jpayne@68: po_file_t file = po_file_read (filename, &handler);
jpayne@68: 
jpayne@68: {
jpayne@68:   const char * const *domains = po_file_domains (file);
jpayne@68:   const char * const *domainp;
jpayne@68: 
jpayne@68:   /* Iterate the domains contained in the file.  */
jpayne@68:   for (domainp = domains; *domainp; domainp++)
jpayne@68:     {
jpayne@68:       po_message_t *message;
jpayne@68:       const char *domain = *domainp;
jpayne@68:       po_message_iterator_t iterator = po_message_iterator (file, domain);
jpayne@68: 
jpayne@68:       /* Iterate each message inside the domain.  */
jpayne@68:       while ((message = po_next_message (iterator)) != NULL)
jpayne@68:         {
jpayne@68:           /* Read data from the message …  */
jpayne@68:           const char *msgid = po_message_msgid (message);
jpayne@68:           const char *msgstr = po_message_msgstr (message);
jpayne@68: 
jpayne@68:           …
jpayne@68: 
jpayne@68:           /* Modify its contents …  */
jpayne@68:           if (perform_some_tests (msgid, msgstr))
jpayne@68:             po_message_set_fuzzy (message, 1);
jpayne@68: 
jpayne@68:           …
jpayne@68:         }
jpayne@68:       /* Always release returned po_message_iterator_t.  */
jpayne@68:       po_message_iterator_free (iterator);
jpayne@68:     }
jpayne@68: 
jpayne@68:   /* Write back the result.  */
jpayne@68:   po_file_t result = po_file_write (file, filename, &handler);
jpayne@68: }
jpayne@68: 
jpayne@68: /* Always release the returned po_file_t.  */
jpayne@68: po_file_free (file);
jpayne@68: 
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.1 Error Handling

jpayne@68: jpayne@68:

Error management is performed through callbacks provided by the user of jpayne@68: the library. They are provided through a parameter with the following jpayne@68: type: jpayne@68:

jpayne@68:
jpayne@68:
Data Type: struct po_xerror_handler jpayne@68: jpayne@68:
jpayne@68:

Its pointer is defined as po_xerror_handler_t. Contains jpayne@68: two fields, xerror and xerror2, with the following function jpayne@68: signatures. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void xerror (int severity, po_message_t message, const char *filename, size_t lineno, size_t column, int multiline_p, const char *message_text) jpayne@68: jpayne@68:
jpayne@68:

This function is called to signal a problem of the given severity. jpayne@68: It must not return if severity is jpayne@68: PO_SEVERITY_FATAL_ERROR. jpayne@68:

jpayne@68:

message_text is the problem description. When multiline_p jpayne@68: is true, it can contain multiple lines of text, each terminated with a jpayne@68: newline, otherwise a single line. jpayne@68:

jpayne@68:

message and/or filename and lineno indicate where the jpayne@68: problem occurred: jpayne@68:

jpayne@68: jpayne@68:
jpayne@68: jpayne@68:
jpayne@68:
Function: void xerror2 (int severity, po_message_t message1, const char *filename1, size_t lineno1, size_t column1, int multiline_p1, const char *message_text1, po_message_t message2, const char *filename2, size_t lineno2, size_t column2, int multiline_p2, const char *message_text2) jpayne@68: jpayne@68:
jpayne@68:

This function is called to signal a problem of the given severity jpayne@68: that refers to two messages. It must not return if jpayne@68: severity is PO_SEVERITY_FATAL_ERROR. jpayne@68:

jpayne@68:

It is similar to two calls to xerror. If possible, an ellipsis can be jpayne@68: appended to message_text1 and prepended to message_text2. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.2 po_file_t API

jpayne@68: jpayne@68:
jpayne@68:
Data Type: po_file_t jpayne@68: jpayne@68:
jpayne@68:

This is a pointer type that refers to the contents of a PO file, after it has jpayne@68: been read into memory. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: po_file_t po_file_create () jpayne@68: jpayne@68:
jpayne@68:

The po_file_create function creates an empty PO file representation in jpayne@68: memory. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: po_file_t po_file_read (const char *filename, struct po_xerror_handler *handler) jpayne@68: jpayne@68:
jpayne@68:

The po_file_read function reads a PO file into memory. The file name jpayne@68: is given as argument. The return value is a handle to the PO file's contents, jpayne@68: valid until po_file_free is called on it. In case of error, the jpayne@68: functions from handler are called to signal it. jpayne@68:

jpayne@68:

This function is exported as ‘po_file_read_v3’ at ABI level, but is jpayne@68: defined as po_file_read in C code after the inclusion of jpayne@68: ‘<gettext-po.h>’. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: po_file_t po_file_write (po_file_t file, const char *filename, struct po_xerror_handler *handler) jpayne@68: jpayne@68:
jpayne@68:

The po_file_write function writes the contents of the memory jpayne@68: structure file the filename given. The return value is jpayne@68: file after a successful operation. In case of error, the jpayne@68: functions from handler are called to signal it. jpayne@68:

jpayne@68:

This function is exported as ‘po_file_write_v2’ at ABI level, but jpayne@68: is defined as po_file_write in C code after the inclusion of jpayne@68: ‘<gettext-po.h>’. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_file_free (po_file_t file) jpayne@68: jpayne@68:
jpayne@68:

The po_file_free function frees a PO file's contents from memory, jpayne@68: including all messages that are only implicitly accessible through iterators. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * const * po_file_domains (po_file_t file) jpayne@68: jpayne@68:
jpayne@68:

The po_file_domains function returns the domains for which the given jpayne@68: PO file has messages. The return value is a NULL terminated array jpayne@68: which is valid as long as the file handle is valid. For PO files which jpayne@68: contain no ‘domain’ directive, the return value contains only one domain, jpayne@68: namely the default domain "messages". jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.3 po_message_iterator_t API

jpayne@68: jpayne@68:
jpayne@68:
Data Type: po_message_iterator_t jpayne@68: jpayne@68:
jpayne@68:

This is a pointer type that refers to an iterator that produces a sequence of jpayne@68: messages. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: po_message_iterator_t po_message_iterator (po_file_t file, const char *domain) jpayne@68: jpayne@68:
jpayne@68:

The po_message_iterator returns an iterator that will produce the jpayne@68: messages of file that belong to the given domain. If domain jpayne@68: is NULL, the default domain is used instead. To list the messages, jpayne@68: use the function po_next_message repeatedly. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_iterator_free (po_message_iterator_t iterator) jpayne@68: jpayne@68:
jpayne@68:

The po_message_iterator_free function frees an iterator previously jpayne@68: allocated through the po_message_iterator function. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: po_message_t po_next_message (po_message_iterator_t iterator) jpayne@68: jpayne@68:
jpayne@68:

The po_next_message function returns the next message from jpayne@68: iterator and advances the iterator. It returns NULL when the jpayne@68: iterator has reached the end of its message list. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.4 po_message_t API

jpayne@68: jpayne@68:
jpayne@68:
Data Type: po_message_t jpayne@68: jpayne@68:
jpayne@68:

This is a pointer type that refers to a message of a PO file, including its jpayne@68: translation. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: po_message_t po_message_create (void) jpayne@68: jpayne@68:
jpayne@68:

Returns a freshly constructed message. To finish initializing the jpayne@68: message, you must set the msgid and msgstr. It must be jpayne@68: inserted into a file to manage its memory, as there is no jpayne@68: po_message_free available to the user of the library. jpayne@68:

jpayne@68: jpayne@68:

The following functions access details of a po_message_t. Recall jpayne@68: that the results are valid as long as the file handle is valid. jpayne@68:

jpayne@68:
jpayne@68:
Function: const char * po_message_msgctxt (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_msgctxt function returns the msgctxt, the jpayne@68: context of message. Returns NULL for a message not restricted jpayne@68: to a context. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_msgctxt (po_message_t message, const char *msgctxt) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_msgctxt function changes the msgctxt, jpayne@68: the context of the message, to the value provided through jpayne@68: msgctxt. The value NULL removes the restriction. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_msgid (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_msgid function returns the msgid (untranslated jpayne@68: English string) of message. This is guaranteed to be non-NULL. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_msgid (po_message_t message, const char *msgid) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_msgid function changes the msgid jpayne@68: (untranslated English string) of message to the value provided through jpayne@68: msgid, a non-NULL string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_msgid_plural (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_msgid_plural function returns the msgid_plural jpayne@68: (untranslated English plural string) of message, a message with plurals, jpayne@68: or NULL for a message without plural. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_msgid_plural (po_message_t message, const char *msgid_plural) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_msgid_plural function changes the jpayne@68: msgid_plural (untranslated English plural string) of a message to jpayne@68: the value provided through msgid_plural, or removes the plurals if jpayne@68: NULL is provided as msgid_plural. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_msgstr (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_msgstr function returns the msgstr (translation) jpayne@68: of message. For an untranslated message, the return value is an empty jpayne@68: string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_msgstr (po_message_t message, const char *msgstr) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_msgstr function changes the msgstr jpayne@68: (translation) of message to the value provided through msgstr, a jpayne@68: non-NULL string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_msgstr_plural (po_message_t message, int index) jpayne@68: jpayne@68:
jpayne@68:

The po_message_msgstr_plural function returns the jpayne@68: msgstr[index] of message, a message with plurals, or jpayne@68: NULL when the index is out of range or for a message without jpayne@68: plural. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_msgstr_plural (po_message_t message, int index, const char *msgstr_plural) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_msgstr_plural function changes the jpayne@68: msgstr[index] of message, a message with plurals, to jpayne@68: the value provided through msgstr_plural. message must be a jpayne@68: message with plurals. jpayne@68: Use NULL as the value of msgstr_plural with jpayne@68: index pointing to the last element to reduce the number of plural jpayne@68: forms. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_comments (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_comments function returns the comments of message, jpayne@68: a multiline string, ending in a newline, or a non-NULL empty string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_comments (po_message_t message, const char *comments) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_comments function changes the comments of jpayne@68: message to the value comments, a multiline string, ending in a jpayne@68: newline, or a non-NULL empty string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_extracted_comments (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_extracted_comments function returns the extracted jpayne@68: comments of message, a multiline string, ending in a newline, or a jpayne@68: non-NULL empty string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_extracted_comments (po_message_t message, const char *extracted_comments) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_extracted_comments function changes the jpayne@68: comments of message to the value extracted_comments, a multiline jpayne@68: string, ending in a newline, or a non-NULL empty string. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_prev_msgctxt (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_prev_msgctxt function returns the previous jpayne@68: msgctxt, the previous context of message. Return jpayne@68: NULL for a message that does not have a previous context. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_prev_msgctxt (po_message_t message, const char *prev_msgctxt) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_prev_msgctxt function changes the previous jpayne@68: msgctxt, the context of the message, to the value provided jpayne@68: through prev_msgctxt. The value NULL removes the stored jpayne@68: previous msgctxt. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_prev_msgid (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_prev_msgid function returns the previous jpayne@68: msgid (untranslated English string) of message, or jpayne@68: NULL if there is no previous msgid stored. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_prev_msgid (po_message_t message, const char *prev_msgid) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_prev_msgid function changes the previous jpayne@68: msgid (untranslated English string) of message to the value jpayne@68: provided through prev_msgid, or removes the message when it is jpayne@68: NULL. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_message_prev_msgid_plural (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_prev_msgid_plural function returns the previous jpayne@68: msgid_plural (untranslated English plural string) of jpayne@68: message, a message with plurals, or NULL for a message jpayne@68: without plural without any stored previous msgid_plural. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_prev_msgid_plural (po_message_t message, const char *prev_msgid_plural) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_prev_msgid_plural function changes the jpayne@68: previous msgid_plural (untranslated English plural string) of a jpayne@68: message to the value provided through prev_msgid_plural, or jpayne@68: removes the stored previous msgid_plural if NULL is jpayne@68: provided as prev_msgid_plural. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: int po_message_is_obsolete (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_is_obsolete function returns true when message jpayne@68: is marked as obsolete. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_obsolete (po_message_t message, int obsolete) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_obsolete function changes the obsolete mark of jpayne@68: message. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: int po_message_is_fuzzy (po_message_t message) jpayne@68: jpayne@68:
jpayne@68:

The po_message_is_fuzzy function returns true when message jpayne@68: is marked as fuzzy. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_fuzzy (po_message_t message, int fuzzy) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_fuzzy function changes the fuzzy mark of jpayne@68: message. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: int po_message_is_format (po_message_t message, const char *format_type) jpayne@68: jpayne@68:
jpayne@68:

The po_message_is_format function returns true when the message jpayne@68: is marked as being a format string of format_type. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_format (po_message_t message, const char *format_type, int value) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_fuzzy function changes the format mark of jpayne@68: the message for the format_type provided. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: int po_message_is_range (po_message_t message, int *minp, int *maxp) jpayne@68: jpayne@68:
jpayne@68:

The po_message_is_range function returns true when the message jpayne@68: has a numeric range set, and stores the minimum and maximum value in the jpayne@68: locations pointed by minp and maxp respectively. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_set_range (po_message_t message, int min, int max) jpayne@68: jpayne@68:
jpayne@68:

The po_message_set_range function changes the numeric range of jpayne@68: the message. min and max must be non-negative, with jpayne@68: min < max. Use min and max with value -1 jpayne@68: to remove the numeric range of message. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.5 PO Header Entry API

jpayne@68: jpayne@68:

The following functions provide an interface to extract and manipulate jpayne@68: the header entry (see section Filling in the Header Entry) from a file loaded in memory. jpayne@68: The meta information must be written back into the domain message with jpayne@68: the empty string as msgid. jpayne@68:

jpayne@68:
jpayne@68:
Function: const char * po_file_domain_header (po_file_t file, const char *domain) jpayne@68: jpayne@68:
jpayne@68:

Returns the header entry of a domain from file, a PO file loaded in jpayne@68: memory. The value NULL provided as domain denotes the jpayne@68: default domain. Returns NULL if there is no header entry. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: char * po_header_field (const char *header, const char *field) jpayne@68: jpayne@68:
jpayne@68:

Returns the value of field in the header entry. The return jpayne@68: value is either a freshly allocated string, to be freed by the caller, jpayne@68: or NULL. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: char * po_header_set_field (const char *header, const char *field, const char *value) jpayne@68: jpayne@68:
jpayne@68:

Returns a freshly allocated string which contains the entry from jpayne@68: header with field set to value. The field is added if jpayne@68: necessary. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.6 po_filepos_t API

jpayne@68: jpayne@68:
jpayne@68:
Data Type: po_filepos_t jpayne@68: jpayne@68:
jpayne@68:

This is a pointer type that refers to a string's position within a jpayne@68: source file. jpayne@68:

jpayne@68: jpayne@68:

The following functions provide an interface to extract and manipulate jpayne@68: these references. jpayne@68:

jpayne@68:
jpayne@68:
Function: po_filepos_t po_message_filepos (po_message_t message, int index) jpayne@68: jpayne@68:
jpayne@68:

Returns the file reference in position index from the message. If jpayne@68: index is out of range, returns NULL. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_remove_filepos (po_message_t message, int index) jpayne@68: jpayne@68:
jpayne@68:

Removes the file reference in position index from the message. It jpayne@68: moves all references following index one position backwards. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_add_filepos (po_message_t message, const char *file, size_t start_line) jpayne@68: jpayne@68:
jpayne@68:

Adds a reference to the string from file starting at jpayne@68: start_line, if it is not already present for the message. The jpayne@68: value (size_t)(-1) for start_line denotes that the line jpayne@68: number is not available. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.7 Format Type API

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * const * po_format_list (void) jpayne@68: jpayne@68:
jpayne@68:

Returns a NULL terminated array of the supported format types. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: const char * po_format_pretty_name (const char *format_type) jpayne@68: jpayne@68:
jpayne@68:

Returns the pretty name associated with format_type. For example, jpayne@68: it returns “C#” when format_type is “csharp_format”. jpayne@68: Return NULL if format_type is not a supported format type. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:

9.13.8 Checking API

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_file_check_all (po_file_t file, po_xerror_handler_t handler) jpayne@68: jpayne@68:
jpayne@68:

Tests whether the entire file is valid, like msgfmt does it. If it jpayne@68: is invalid, passes the reasons to handler. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_check_all (po_message_t message, po_message_iterator_t iterator, po_xerror_handler_t handler) jpayne@68: jpayne@68:
jpayne@68:

Tests message, to be inserted at iterator in a PO file in memory, jpayne@68: like msgfmt does it. If it is invalid, passes the reasons to jpayne@68: handler. iterator is not modified by this call; it only jpayne@68: specifies the file and the domain. jpayne@68:

jpayne@68: jpayne@68:
jpayne@68:
Function: void po_message_check_format (po_message_t message, po_xerror_handler_t handler) jpayne@68: jpayne@68:
jpayne@68:

Tests whether the message translation from message is a valid jpayne@68: format string if the message is marked as being a format string. If it jpayne@68: is invalid, passes the reasons to handler. jpayne@68:

jpayne@68:

This function is exported as ‘po_message_check_format_v2’ at ABI jpayne@68: level, but is defined as po_message_check_format in C code after jpayne@68: the inclusion of ‘<gettext-po.h>’. jpayne@68:

jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:
[ << ][ >> ]           [Top][Contents][Index][ ? ]
jpayne@68:

jpayne@68: jpayne@68: This document was generated by Bruno Haible on February, 21 2024 using texi2html 1.78a. jpayne@68: jpayne@68:
jpayne@68: jpayne@68:

jpayne@68: jpayne@68: