LinuxCommandLibrary

gencat

Generate message catalogs

SYNOPSIS

gencat [-n] catfile msgfile [msgfile ...]

PARAMETERS

-n
    Suppress warning messages for duplicate message numbers within sets or when $DELSET directives appear in input files.

DESCRIPTION

gencat is a utility for compiling message source files into a binary message catalog used by the catopen(), catgets(), and catclose() library functions. These functions enable runtime retrieval of locale-specific messages, supporting application internationalization via Native Language Support (NLS).

Input files (msgfiles) contain message sets defined by $set n directives (where n is a set ID), followed by message lines like m "text" (message ID m and text). Directives include $delset n to remove sets, $quote to change quote character, and comments starting with #. Multiple input files are processed sequentially; sets merge across files.

By default, gencat warns on duplicate message IDs in sets or $DELSET directives. The catalog output (catfile) is binary and used with environment variables like NLSPATH or LC_MESSAGES. It supports multi-byte locales and is efficient for large catalogs.

This contrasts with GNU gettext's msgfmt, which produces .mo files for a different API.

CAVEATS

Catalogs are architecture-dependent (endianness, padding) and not portable across systems.
Limits exist on set/message IDs (often 32767 max).
Not compatible with gettext .mo files.

MESSAGE FILE FORMAT

$set n — Start set n (positive integer).

m "message text" — Message ID m with text (quoted, continuable with \).

$delset n — Delete prior set n.

# comment — Ignored line.

$quote c — Set quote char to c.

EXAMPLE

echo '$set 1 1 "Hello"' | gencat hello.cat -

Then in C: catopen("hello.cat", NL_CAT_LOCALE);

HISTORY

Introduced in AT&T UNIX System V Release 3.2 (1987) for NLS. Adopted in XPG3 (1989), POSIX.1-2001. Maintained in modern Unix-like systems via glibc or standalone.

SEE ALSO

msgfmt(1), localedef(1), locale(1)

Copied to clipboard