
- Unix Commands Reference
- Unix Commands - Home
gettext - Unix, Linux Command
NAME
gettext - translate messageSYNOPSIS
gettext [OPTION] [[TEXTDOMAIN] MSGID]gettext [OPTION] -s [MSGID]...
DESCRIPTION
The gettext program translates a natural language message into the users language, by looking up the translation in a message catalog.Display native language translation of a textual message.
Tag | Description |
---|---|
-d, --domain=TEXTDOMAIN | |
retrieve translated messages from TEXTDOMAIN | |
-e | enable expansion of some escape sequences |
-E | (ignored for compatibility) |
-h, --help | display this help and exit |
-n | suppress trailing newline |
-V, --version | |
display version information and exit | |
[TEXTDOMAIN] MSGID | |
retrieve translated message corresponding to MSGID from TEXTDOMAIN |
EXAMPLES
gettext is an internationalization and localization system commonly used for writing multilingual programs. For gettext to work, the message catalogue is required.
Below are the steps in creating message catalogue:1. Modify source code to use gettext calls
$ cat test.sh gettext -s "This message to be translated"
2. run xgettext to generate .pot (Portable Object Template) file
$ xgettext -c /This will create file which will look similar like below
msgid "This message to be translated" msgstr ""
3. Translate to create .po (Portable object) file
$ msginit --locale=es --input=name.potThe .po file has to be modified to ener the translated message.
msgid "This message to be translated" msgstr "This is a translated message"
4. Create .mo (Machine Object) file
$ msginit --locale=es --input=es.pot
5. To see the translated message user has to change the LC_MESSAGE variable
Advertisements