git-sh-i18n–envsubst - Linux


git-sh-i18n–envsubst leverages the envsubst command to embed variables and translate text into your shell’s environment. It complements the core Git translation mechanism, allowing you to internationalize your Git scripts and message templates.


git sh-i18n--envsubst [options] [<variables>]


  • -s : Supply input text directly, rather than from stdin.
  • -m: Merge environment variables from current Git environment into the environment passed to envsubst.
  • -f : Set the envsubst format (defaults to plaintext).
  • -N : Explicitly specify the language, overriding automatic detection.
  • -v: Enable verbose output, including language detection and variable replacement details.


Simple Translation:

Translate text using the current language set in your Git configuration:

git sh-i18n--envsubst <<EOF
Subject: ${MSG_SUBJECT} (localized)

Merging Environment Variables:

Keep variables from Git’s translation mechanism:

git sh-i18n--envsubst -m <<EOF
Subject: ${MSG_SUBJECT} (original)

Using Direct Input:

Provide text directly, instead of reading from stdin:

git sh-i18n--envsubst -s "Subject: ${MSG_SUBJECT} (inline)"

Explicit Language Override:

Enforce a specific language, regardless of system settings:

git sh-i18n--envsubst -N en <<EOF
Subject: ${MSG_SUBJECT} (enforced English)

Common Issues

  • Missing Variables: Ensure that variables are correctly capitalized and exist in your active translation file.
  • Incorrect Language Detection: Adjust your Git configuration to set the desired default language or use the -N option.


Combine with other commands to automate translations:

git commit --message-encoding utf-8 $(git sh-i18n--envsubst)

Related Commands

  • envsubst: Embed environment variables into text.
  • git-i18n: Manage Git translation files.