How to change the language of my git?

2020-03-08 07:59发布

My ˋgitˋ is in german, it says:

ˋAuf Zweig masterˋ

instead of

On branch master

with git status.

What's the reason for this?

4条回答
你好瞎i
2楼-- · 2020-03-08 08:41

Sometimes changing the LANG environment variable alone is not good enough.

You may also need to add LC_ALL

export LC_ALL=en_US.UTF-8

According to The IEEE and The Open Group - Environment Variables.

It is because the environment variables starting by LC_* will be used first by your system before LANG:

The values of locale categories shall be determined by a precedence order; the first condition met below determines the value:

  1. If the LC_ALL environment variable is defined and is not null, the value of LC_ALL shall be used.

  2. If the LC_* environment variable (LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME) is defined and is not null, the value of the environment variable shall be used to initialize the category that corresponds to the environment variable.

  3. If the LANG environment variable is defined and is not null, the value of the LANG environment variable shall be used.

  4. If the LANG environment variable is not set or is set to the empty string, the implementation-defined default locale shall be used.

To change it permanently, you need to paste the code above into your favourite shell configuration file (probably ~/.bashrc or ~/.zshrc)

Then to apply the modification do:

$ source ~/.bashrc

or

$ source ~/.zshrc

Otherwise, just open a new terminal.

查看更多
家丑人穷心不美
3楼-- · 2020-03-08 08:49

In my case, setting LANG or LC_ALL was not enough. I also had a LANGUAGE environment variable which was set to en_GB:en_US:de. Despite the ordering, which is presumably an order of preference, it resulted in a German language response from git and other commandline-programmes. When I changed it to en_GB:en_US, git and other programmes became English.

查看更多
看我几分像从前
4楼-- · 2020-03-08 08:53

The reason for this is that your command line language is set to German. So when you do:

echo $LANG

you will see:

de_DE.UTF-8

To change this, do:

echo "export LANG=en_US.UTF-8" >> ~/.bashrc

assuming your standard shell is bash.

Don't forget:

source ~/.bashrc
查看更多
做个烂人
5楼-- · 2020-03-08 08:56

Probably you locale is german. You can see it by locale. Try to change it by: export LANG="en_US.UTF-8"

查看更多
登录 后发表回答