LinuxCommandLibrary

gettext

internationalization message catalog lookup

TLDR

Display translated string

$ gettext [domain] "[message]"
copy
Translate from catalog
$ TEXTDOMAIN=[domain] gettext "[message]"
copy
With context
$ gettext -c "[context]" "[message]"
copy
Plural forms
$ ngettext "[singular]" "[plural]" [count]
copy

SYNOPSIS

gettext [options] [domain] msgid

DESCRIPTION

gettext retrieves translated strings from message catalogs. It's the runtime component of the GNU internationalization system, looking up translations based on the current locale.
The tool searches .mo files for translations, returning the original if none found. It enables shell scripts and programs to produce localized output.
gettext enables internationalization of command-line applications.

PARAMETERS

DOMAIN

Message catalog domain.
MSGID
Message to translate.
-d DOMAIN
Text domain.
-e
Enable escape interpretation.
-E
Preserve but don't interpret backslashes.
-c CONTEXT
Message context.
--help
Display help information.

CONFIGURATION

/usr/share/locale/[LANG]/LC_MESSAGES/[domain].mo

Compiled message catalogs containing translations for specific domains and locales.

CAVEATS

Requires compiled .mo catalogs. LANG/LC_MESSAGES must be set. Missing translations return original.

HISTORY

gettext was developed by GNU for internationalization. It became the standard Unix localization system, enabling software to support multiple languages.

SEE ALSO

xgettext(1), msgfmt(1), envsubst(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community