gettext -- retrieve text string from message database


gettext [ options ] [ textdomain ] msgid

gettext -s [ options ] msgid ...


The gettext utility retrieves a translated text string corresponding to string msgid from a message object generated with msgfmt utility.

The message object name is derived from the optional argument textdomain if present, otherwise from the TEXTDOMAIN environment. If no domain is specified, or if a corresponding string cannot be found, gettext prints msgid.

Ordinarily gettext looks for its message object in dirname/lang/LC_MESSAGES where dirname is the implementation-defined default directory and lang is the locale name. If present, the TEXTDOMAINDIR environment variable replaces the dirname.

This utility interprets C escape sequences such as \t for tab. Use \\ to print a backslash. To produce a message on a line of its own, either put a \n at the end of msgid, or use this command in conjunction with printf utility.

When used with the -s option the utility behaves like the echo utility. But it does not simply copy its arguments to standard output. Instead those messages found in the selected catalog are translated.


-d domainname, --domain=domainname

Retrieve translated messages from domainname.


Enable expansion of some escape sequences.


Suppress trailing newline.


The following operands are supported:


A domain name used to retrieve the messages.


A key to retrieve the localized message.

Environment Variables


Specifies one or more locale names. See gettext message handling functions for more information.


Specifies locale name.


Specifies messaging locale, and if present overrides LANG for messages.


Specifies the text domain name, which is identical to the message object filename without .mo suffix.


Specifies the pathname to the message database, and if present replaces the implementation-defined default directory.

Exit Status

The following exit values are returned:


Successful completion.


An error occurred.