The locale is the configuration of a Linux system that provides a region, keyboard, time-related data. The locale is important because it will change the interpretation of some keyboards etc. If you are getting the following warning like “Setting locale failed” we will look at how to solve it.
语言环境是Linux系统的配置,提供了区域,键盘和与时间相关的数据。 语言环境很重要,因为它会更改某些键盘等的解释。如果收到“设置语言环境失败”之类的警告,我们将研究如何解决。
列出当前区域设置 (List Current Locale Setting)
Listing of current locale settings can be done just by issuing locale commands. We do not need to provide an option for listing.
仅通过发出区域设置命令即可列出当前区域设置。 我们不需要提供上市选项。
$ locale
As we can see that there are different locale settings like TIME
, ADDRESS
, MEASUREMENT
, MONETARY
etc.
如我们所见,有不同的语言环境设置,例如TIME
, ADDRESS
, MEASUREMENT
, MONETARY
等。
更改局部变量 (Change Local Variable)
We see that LC_ALL
environment variable is not set and the problem is that some application needs this locale to be set. We will use update-locale
command in order to change the current locale. We will also provide the locale we want to set which is en_US.UTF-8
in this example.
我们看到未设置LC_ALL
环境变量,问题是某些应用程序需要设置此语言环境。 我们将使用update-locale
命令来更改当前语言环境。 在此示例中,我们还将提供要设置的语言环境,即en_US.UTF-8
。
$ sudo update-locale LC_ALL="en_US.UTF-8"
update-locale
is a command which will update locale configurationupdate-locale
是将更新语言环境配置的命令LC_ALL="en_US.UTF-8"
is the locale variable we want to updateLC_ALL="en_US.UTF-8"
是我们要更新的语言环境变量
$ locale
To effect the settings log out and log in for locale command.
要使设置生效,请注销并登录locale命令。