LinuxCommandLibrary

git-sh-i18n

Translate Git messages into other languages

SYNOPSIS

git sh-i18n [--help] [--env] [--ts <locale.mo>] [--no-ts]

PARAMETERS

--help
    Display usage and exit

--env
    Output only environment setup code, no functions

--ts <locale.mo>
    Use specified message catalog file

--no-ts
    Skip loading any translation file

DESCRIPTION

git-sh-i18n is a Git plumbing tool that generates shell code for internationalization in scripts. It provides functions like gettext(), eval_gettext(), and _() (gettext alias) to handle string translations using gettext catalogs (.mo files).

Invoke via eval "$(git sh-i18n [options])" to load the library, or source it directly as . "$(git --exec-path)/git-sh-i18n". Options customize translation setup: specify locale file, skip loading, or limit to environment vars.

Used internally by Git shell scripts (e.g., git-rebase.sh) for localized output. Emulates GNU gettext in POSIX shell. Supports plural forms via ngettext(), eval_ngettext(). Ensures TEXTDOMAIN=git, TEXTDOMAINDIR points to Git's locale dir.

CAVEATS

Internal Git tool; not for end-user scripts. Requires Git installation and gettext support.

KEY FUNCTIONS

gettext STR: Return translation of STR.
eval_gettext "$@": Eval args as format string, then translate.
_ STR: Synonym for gettext.
ngettext SING PLUR N: Plural form translation.

USAGE EXAMPLE

eval "$(git sh-i18n --ts git-mo-de.mo)"
echo "$(gettext 'Hello')"

HISTORY

Added in Git 1.5.3 (2007) for shell i18n. Improved in later versions for plural support and eval helpers.

SEE ALSO

Copied to clipboard