1. Check whether the Chinese package is installed
You can use the following names to check whether the Chinese installation package is installed on the system.
locale -a |grep "zh_CN"
There is no output, indicating that it is not installed, enter the following command to install:
yum groupinstall "fonts" -y
After the installation is complete, check which Chinese language packs are installed
[root@iz2ze6adlpez0gy7j13vrmz /]# locale -a | grep "zh_CN" zh_CN zh_CN.gb18030 zh_CN.gb2312 zh_CN.gbk zh_CN.utf8
It means that the Chinese language pack has been installed in the system, and there is no need to install it again. Important note, if your system still cannot use Chinese after following the steps below, please try the above encoding methods one by one. For example, change LANG="zh_CN" to LANG="zh_CN.gb18030".
2 Modify the configuration file
Before modifying the configuration file, let's take a look at the current system locale:
# echo $LONG en_US.UTF-8 # locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
Although the Chinese language pack is installed, the locale of the machine is not Chinese, and the locale.conf configuration file needs to be modified
# vim /etc/locale.conf LANG="zh_CN" # source /etc/locale.conf
The locale.conf configuration file can also be modified with the command:
# localectl set-locale LANG=zh_CN
Then view the current locale:
# echo $LANG zh_CN # locale LANG=zh_CN LC_CTYPE="zh_CN" LC_NUMERIC="zh_CN" LC_TIME="zh_CN" LC_COLLATE="zh_CN" LC_MONETARY="zh_CN" LC_MESSAGES="zh_CN" LC_PAPER="zh_CN" LC_NAME="zh_CN" LC_ADDRESS="zh_CN" LC_TELEPHONE="zh_CN" LC_MEASUREMENT="zh_CN" LC_IDENTIFICATION="zh_CN" LC_ALL=
3. Verify success
[root@node2 ~] # date Mon 16 Oct 2017 16:30:24 CST
4. Command Supplementary Explanation
locale -a |grep "zh_CN" : list the names of all available common locales, then filter for Chinese
locale -a : List the names of all available common locales.
If you can see the following items, it also means that the Chinese language pack has been installed in the system. No need to install again, what do these items mean?
{language code}_{country code}.{character set}
zh is the code name of Chinese, CN is the code name of China, gb18030, gb2312, utf8 is the language character set
Then each item can be understood as "you speak Chinese, you are in China, and the language character set is gb18030/gb2312/utf8"
If the above items are not found, manually install the Chinese language pack
# yum install kde-l10n-Chinese (about 11M)
locale : View the current system locale
("en_US.UTF-8" can be understood as "you speak English, you are in the United States, and the language character set is UTF-8" according to the above content)
The meaning of each item is:
LANG: The language of the current system
LC_CTYPE: language symbols and their classification
LC_NUMERIC: Number
LC_COLLATE: comparison and sorting conventions
LC_TIME: time display format
LC_MONETARY: monetary unit
LC_MESSAGES: Information is mainly prompt information, error information, status information, title, label, button and menu, etc.
LC_NAME: Name writing style
LC_ADDRESS: address notation
LC_TELEPHONE: Phone number notation
LC_MEASUREMENT: Metrics expression
LC_PAPER: Default paper size
LC_IDENTIFICATION: an overview of the information contained in the locale itself
LC_ALL: the highest priority variable, if this variable is set, all LC_* and LANG variables will be forced to follow its value
We see that although the Chinese language pack is installed, the locale of the machine is not Chinese
reboot the system
# reboot
Article references and sources:
1.https://www.cnblogs.com/sisimi/p/7693226.html
2.https://www.linuxidc.com/Linux/2017-07/145572.htm