如何更改我的 git 的语言?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11540815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:14:30  来源:igfitidea点击:

How to change the language of my git?

linuxgitcommand-lineterminal

提问by kadrian

My ˋgitˋ is in german, it says:

我的ˋgitˋ是德语,它说:

ˋAuf Zweig masterˋ

ˋ奥夫茨威格大师ˋ

instead of

代替

On branch master

On branch master

with git status.

git status.

What's the reason for this?

这是什么原因?

回答by Aleksey Bakin

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

可能你的语言环境是德语。你可以看到它locale。尝试通过以下方式更改它:export LANG="en_US.UTF-8"

回答by kadrian

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.

假设您的标准 shell 是 bash。

Don't forget:

不要忘记:

source ~/.bashrc

回答by Kruup?s

Sometimes changing the LANGenvironment variable alone is not good enough.

有时LANG仅仅改变环境变量是不够的。

You may also need to add LC_ALL

您可能还需要添加 LC_ALL

export LC_ALL=en_US.UTF-8

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

根据IEEE 和开放组 - 环境变量

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

这是因为您的系统LC_*将首先使用以开头的环境变量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.

语言环境类别的值应由优先顺序确定;下面满足的第一个条件决定了该值:

  1. 如果 LC_ALL 环境变量已定义且不为空,则应使用 LC_ALL 的值。

  2. 如果定义了 LC_* 环境变量(LC_COLLATE、LC_CTYPE、LC_MESSAGES、LC_MONETARY、LC_NUMERIC、LC_TIME)并且不为空,则应使用环境变量的值来初始化与环境变量对应的类别。

  3. 如果 LANG 环境变量已定义且不为空,则应使用 LANG 环境变量的值。

  4. 如果 LANG 环境变量未设置或设置为空字符串,则应使用实现定义的默认语言环境。

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

要永久更改它,您需要将上面的代码粘贴到您喜欢的 shell 配置文件中(可能~/.bashrc~/.zshrc

Then to apply the modification do:

然后应用修改:

$ source ~/.bashrc

or

或者

$ source ~/.zshrc

Otherwise, just open a new terminal.

否则,只需打开一个新终端。

回答by gerrit

In my case, setting LANGor LC_ALLwas not enough. I also had a LANGUAGEenvironment 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 gitand other commandline-programmes. When I changed it to en_GB:en_US, gitand other programmes became English.

就我而言,设置LANGLC_ALL还不够。我还有一个LANGUAGE环境变量设置为en_GB:en_US:de. 尽管排序,这大概是一个优先顺序,它导致来自git和其他命令行程序的德语响应。当我把它改成 时en_GB:en_USgit其他程序就变成了英文。