Progress:
TIER 2 · MODULE 55· Intermediate

git sh-i18n

Internationalization plumbing for shell-based commands.

🎯 What & why

Internal i18n helper: the gettext wrapper Git's shell-script subcommands use to emit translated messages. Effectively a portable shim around gettext.sh.

🧠 Mental model

A tiny shell library, not really a command. Sourced or invoked by Git's .sh plumbing to translate user-facing strings and substitute variables, falling back to passthrough when gettext isn't built in.

🛠️ Synopsis

git sh-i18n--envsubst <format>
# More commonly sourced by other scripts:
. "$(git --exec-path)/git-sh-i18n"
gettext "untranslated string"
eval_gettext "Hello, \$user"

🎚️ Switches & options

FlagWhat it does
--envsubstSubstitute $VAR references in the supplied format string from the environment
(sourced) gettextTranslate a literal string via the message catalog
(sourced) eval_gettextTranslate, then expand $var references safely
(sourced) eval_ngettextPlural form of eval_gettext, picks singular/plural by count

💡 Use cases

🧪 Examples

Source it inside a shell script
. "$(git --exec-path)/git-sh-i18n"
Translate a literal string
gettext 'Switched to a new branch'
Variable-substituting translation
user=alice; eval_gettext 'Hello, \$user'
Direct envsubst invocation
name=world git sh-i18n--envsubst 'Hello, $name'

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.