Homebrew and Git - Wrong language on the command line

I have a strange issue - when I use the git command which comes with the Command Line Tools package, the interface on the command-line is in English, as I want it to be. However, the version installed using Homebrew uses German in its output (I live in Germany, but my system language is set to US English and the computer was actually bought in Singapore, if it matters).

I believe this changed only recently. I had to give my Mac for repair and did so in a German store. Now that I have my computer back I noticed that Git's output is in German, not sure if they did anything to the system settings while they had it. As far as I know, this is the only command-line application that uses German as its language. Here is the output generated by the locale command:

LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I would like to have Git talk to me in English. I know I can set the LANG etc. to English and it would (probably) work, but I would also like to understand where this change may be coming from.

Any ideas?

EDIT: to make things more interesting, I use another Mac that I got from work. It was bought in Germany, the initial language settings were German (which I changed to US English) and everything works fine on it, i.e. both Git installations (CLT and Homebrew) use English. Locale information from the locale command is the same.


Solution 1:

Recently, I've started to observe the same behavior, particularly with git (and after updating to MacOS Mojave). At first, I thought it's an issue with git itself. So, I've reinstalled git with homebrew to no avail.

However, going to "Language & Region" tab in the MacOS "Settings", and removing other languages from the list that you don't need (note: these are different from the keyboard input sources) resulted in git displaying the command output messages in terminal in the desired language (in my case, English).

Notably, this problem occurred to me only in the macOS terminal (and not, e.g., VSCode's terminal).

Solution 2:

I'm having the same issue. After homebrew upgrade git 2.17.0 -> 2.19.1, I find that the new git version starts to respect LANG env variable.

If

LANG="en_US.UTF-8"

or

LANG=

git will use English.

If, e.g.,

LANG="zh_CN.UTF-8"

git use Chinese.

I haven't read the commit logs of git, but I think it's working as intended. Just feel a little odd to see non-English git command line output messages :)

Solution 3:

Add this to your .bash_profile file-- there's a similar bug with PyCharm's terminal component on macOS mojave (10.14).

# locale settings, string mac/chinese/pycharm/git bug
# https://coderwall.com/p/ehvc8w/set-lang-variable-in-osx-terminal-app
export LANG="en_GB.UTF-8"
export LC_COLLATE="en_GB.UTF-8"
export LC_CTYPE="en_GB.UTF-8"
export LC_MESSAGES="en_GB.UTF-8"
export LC_MONETARY="en_GB.UTF-8"
export LC_NUMERIC="en_GB.UTF-8"
export LC_TIME="en_GB.UTF-8"
export LC_ALL=

After doing this, you'll need to restart your system for it to take effect.

Credit goes to this blog post

Solution 4:

From what I can tell, it's a problem with GNU gettext rather than a problem with Git.

It looks like the bug was fixed in GNU gettext v0.20; but, as of this posting, Homebrew unfortunately provides only v0.19.8.1.


I reproduced the problem as follows:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.4
BuildVersion:   18E226
$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
$ defaults read -g AppleLanguages
(
    "en-JP",
    "ja-JP",
    "sv-JP"
)
$ brew info gettext
gettext: stable 0.19.8.1 (bottled) [keg-only]
GNU internationalization (i18n) and localization (l10n) library
https://www.gnu.org/software/gettext/
/usr/local/Cellar/gettext/0.19.8.1 (1,934 files, 17.0MB)
  Poured from bottle on 2016-06-24 at 02:05:52
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gettext.rb
...
$ /usr/local/Cellar/gettext/0.19.8.1/bin/msgcat --version
msgcat (GNU gettext-tools) 0.19.8.1
Copyright (c) 2001-2016 Free Software Foundation, Inc.
Licens GPLv3+: GNU GPL version 3 eller senare <http://gnu.org/licenses/gpl.html>
Detta program "ar fri programvara.  Du kan modifiera och distribuera den.
Det finns inte NAGON SOM HELST GARANTI, till den grad som lagen tillater.
Skrivet av Bruno Haible.
$ sudo filebyproc.d
CPU     ID                    FUNCTION:NAME
...
  2    957              open_nocancel:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/bin
  2    957              open_nocancel:entry msgcat /etc/localtime
  2    957              open_nocancel:entry msgcat /var/db/timezone/zoneinfo/posixrules
  2    957              open_nocancel:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/locale.alias
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/en_JP/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/en/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/ja_JP.eucJP/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/ja_JP.eucjp/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/ja_JP/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/ja.eucJP/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/ja.eucjp/LC_MESSAGES/gettext-tools.mo
  2    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/ja/LC_MESSAGES/gettext-tools.mo
  3    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/sv_JP/LC_MESSAGES/gettext-tools.mo
  3    171                       open:entry msgcat /usr/local/Cellar/gettext/0.19.8.1/share/locale/sv/LC_MESSAGES/gettext-tools.mo