CentOS8 【openeuler】gnome界面切换中文

CentOS 8默认安装时候,如果选成英文,看文档的时候有可能会费劲。

有的时候需要man或者help的时候,看中文文档来的快。

locale命令
[root@C8-3 ~]# locale --help
[root@C8-3 ~]# locale --help
Usage: locale [OPTION...] NAME
or: locale [OPTION...] [-a|-m]
Get locale-specific information.

System information:
-a, --all-locales Write names of available locales
-m, --charmaps Write names of available charmaps

Modify output format:
-c, --category-name Write names of selected categories
-k, --keyword-name Write names of selected keywords
-v, --verbose Print more information

-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version

For bug reporting instructions, please see:
http://www.gnu.org/software/libc/bugs.html.
locale命令实际显示的是/etc/locale.conf中设定的内容

[root@C8-3 ~]# cat /etc/locale.conf
LANG=en_US.utf8
[root@C8-3 ~]# . /etc/locale.conf
[root@C8-3 ~]# locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
查看系统中已有支持的语言
[root@C8-3 ~]# locale -a
C
C.utf8
en_AG
en_AU
en_AU.utf8
en_BW
en_BW.utf8
en_CA
en_CA.utf8
en_DK
en_DK.utf8
en_GB
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.utf8
en_IE
en_IE@euro
en_IE.utf8
en_IL
en_IN
en_NG
en_NZ
en_NZ.utf8
en_PH
en_PH.utf8
en_SC.utf8
en_SG
en_SG.utf8
en_US
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.utf8
en_ZM
en_ZW
en_ZW.utf8
POSIX
发现没有中文

安装中文语言支持扩展包
[root@C8-3 ~]# yum -y install langpacks-zh_CN
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Last metadata expiration check: -1 day, 11:03:52 ago on Thu Nov 5 14:36:43 2020.
Dependencies resolved.

Package Architecture Version Repository Size

Installing:
langpacks-zh_CN noarch 1.0-12.el8 AppStream 9.6 k
Installing weak dependencies:
glibc-langpack-zh x86_64 2.28-101.el8 base 2.1 M

Transaction Summary

Install 2 Packages

Total download size: 2.2 M
Installed size: 15 M
Downloading Packages:
(1/2): langpacks-zh_CN-1.0-12.el8.noarch.rpm 1.1 kB/s | 9.6 kB 00:08
(2/2): glibc-langpack-zh-2.28-101.el8.x86_64.r 175 kB/s | 2.1 MB 00:12

Total 176 kB/s | 2.2 MB 00:12
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : glibc-langpack-zh-2.28-101.el8.x86_64 1/2
Installing : langpacks-zh_CN-1.0-12.el8.noarch 2/2
Running scriptlet: langpacks-zh_CN-1.0-12.el8.noarch 2/2
Verifying : langpacks-zh_CN-1.0-12.el8.noarch 1/2
Verifying : glibc-langpack-zh-2.28-101.el8.x86_64 2/2

Installed:
langpacks-zh_CN-1.0-12.el8.noarch glibc-langpack-zh-2.28-101.el8.x86_64

Complete!
再次查看,发现有中文了
[root@C8-3 ~]# locale -a
C
C.utf8
en_AG
en_AU
en_AU.utf8
en_BW
en_BW.utf8
en_CA
en_CA.utf8
en_DK
en_DK.utf8
en_GB
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.utf8
en_IE
en_IE@euro
en_IE.utf8
en_IL
en_IN
en_NG
en_NZ
en_NZ.utf8
en_PH
en_PH.utf8
en_SC.utf8
en_SG
en_SG.utf8
en_US
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.utf8
en_ZM
en_ZW
en_ZW.utf8
POSIX
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
zh_HK
zh_HK.utf8
zh_SG
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.euctw
zh_TW.utf8
使用localectl命令设定系统语言为中文
查看localectl是否存在
[root@C8-3 ~]# type localectl
localectl is hashed (/usr/bin/localectl)
输入localectl命令并用tab键补全,查看可以跟的参数
[root@C8-3 ~]# localectl
list-keymaps list-x11-keymap-options set-x11-keymap
list-locales list-x11-keymap-variants status
list-x11-keymap-layouts set-keymap
list-x11-keymap-models set-locale
选择set-locale参数 ,tab补全 ,使用LANG=参数查看当前系统支持的语言,相当于locale -a。
[root@C8-3 ~]# localectl set-locale LANG=
C.utf8 en_GB.utf8 en_PH.utf8 zh_CN
en_AG en_HK en_SC.utf8 zh_CN.gb18030
en_AU en_HK.utf8 en_SG zh_CN.gbk
en_AU.utf8 en_IE en_SG.utf8 zh_CN.utf8
en_BW en_IE@euro en_US zh_HK
en_BW.utf8 en_IE.utf8 en_US.iso885915 zh_HK.utf8
en_CA en_IL en_US.utf8 zh_SG
en_CA.utf8 en_IN en_ZA zh_SG.gbk
en_DK en_NG en_ZA.utf8 zh_SG.utf8
en_DK.utf8 en_NZ en_ZM zh_TW
en_GB en_NZ.utf8 en_ZW zh_TW.euctw
en_GB.iso885915 en_PH en_ZW.utf8 zh_TW.utf8
设定系统语言为zh_CN.utf8
[root@C8-3 ~]# localectl set-locale LANG=zh_CN.utf8
查看当前系统语言
[root@C8-3 ~]# locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
发现并没有生效!
[root@C8-3 ~]# type locale
locale is hashed (/usr/bin/locale)
因为重启才会重新加载配置文件

不重启马上生效的办法
手动加载配置文件,使配置文件被加载到内存中去

[root@C8-3 ~]# . /etc/locale.conf
[root@C8-3 ~]# type locale
locale 已被录入哈希表 (/usr/bin/locale)

转载请注明出处:

转载自http://lxfamn.cn/blog

未经允许不得转载:lxfamn » CentOS8 【openeuler】gnome界面切换中文

赞 (0) 打赏

置顶推荐

评论 0

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏