← 返回命令列表

Linux command

gettext 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Display translated string

gettext [domain] "[message]"

Translate from catalog

TEXTDOMAIN=[domain] gettext "[message]"

With context

gettext -c "[context]" "[message]"

Plural forms

ngettext "[singular]" "[plural]" [count]

说明

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.

参数

-d _DOMAIN_
Text domain.
-e
Enable escape interpretation.
-E
Preserve but don't interpret backslashes.
-c _CONTEXT_
Message context.
--help
Display help information.

FAQ

What is the gettext command used for?

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.

How do I run a basic gettext example?

Run `gettext [domain] "[message]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d _DOMAIN_ do in gettext?

Text domain.