Centos8 中文语言配置支持
安装中文语言包
-
如果不知道中文语言包,使用以下命令查看
[09:39:51] root@ive:~ # yum search Chinese 加载插件 "osmsplugin" 失败 : No module named 'librepo' 上次元数据过期检查:0:26:02 前,执行于 2023年07月29日 星期六 09时14分49秒。 ======================================================================================== 名称 和 概况 匹配:Chinese ======================================================================================== fcitx-table-chinese.noarch : Chinese table of Fcitx ibus-table-chinese.noarch : Chinese input tables for IBus ============================================================================================ 名称 匹配:Chinese ============================================================================================ ibus-table-chinese-array.noarch : Array input methods ibus-table-chinese-cangjie.noarch : Cangjie based input methods ibus-table-chinese-cantonese.noarch : Cantonese input methods ibus-table-chinese-easy.noarch : Easy input method ibus-table-chinese-erbi.noarch : Erbi input method ibus-table-chinese-quick.noarch : Quick-to-learn input methods ibus-table-chinese-scj.noarch : Smart Cangjie ibus-table-chinese-stroke5.noarch : Stroke 5 input method ibus-table-chinese-wu.noarch : Wu pronunciation input method ibus-table-chinese-wubi-haifeng.noarch : Haifeng Wubi input method ibus-table-chinese-wubi-jidian.noarch : Jidian Wubi 86 input method, JiShuang 6.0 ibus-table-chinese-yong.noarch : YongMa input method ============================================================================================ 概况 匹配:Chinese ============================================================================================ autocorr-zh.noarch : Chinese auto-correction rules langpacks-zh_CN.noarch : Simplified Chinese langpacks meta-package langpacks-zh_TW.noarch : Traditional Chinese langpacks meta-package libchewing.x86_64 : Intelligent phonetic input method library for Traditional Chinese perl-Encode-HanExtra.x86_64 : Extra sets of Chinese encodings tesseract-langpack-chi_sim.noarch : Chinese (Simplified) language data for tesseract-tessdata tesseract-langpack-chi_sim_vert.noarch : Chinese (Simplified, Vertical) language data for tesseract-tessdata tesseract-langpack-chi_tra.noarch : Chinese (Traditional) language data for tesseract-tessdata tesseract-langpack-chi_tra_vert.noarch : Chinese (Traditional, Vertical) language data for tesseract-tessdata texlive-arphic.noarch : Arphic (Chinese) font packages tomoe.x86_64 : Handwritten input system for Japanese and Chinese wqy-microhei-fonts.noarch : Compact Chinese fonts derived from Droid zinnia-tomoe-zh_CN.x86_64 : Simplified Chinese tomoe model file for zinnia
-
centos8默认推荐使用dnf包管理工具安装软件包
注意默认安装中文语言支持依赖包 "glibc-langpack-zh"
[08:15:41] root@ive:~ # dnf install -y langpacks-zh_CN.noarch Failed to set locale, defaulting to C.UTF-8 Failed loading plugin "osmsplugin": No module named 'librepo' Last metadata expiration check: 2:11:51 ago on Sat Jul 29 06:06:06 2023. 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-228.el8 baseos 2.2 M Transaction Summary ============================================================================================================================================================================================================ Install 2 Packages
-
安装结束查看系统支持语言,如下
[09:40:57] root@ive:~ # 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@ampm en_US.iso885915 en_US.utf8 en_US.utf8@ampm 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
-
查看系统当前的字符集
[09:48:13] root@korea:~ # localectl status System Locale: LANG=en_US.UTF-8 VC Keymap: us X11 Layout: us
也可以直接查看配置文件
[09:50:59] root@korea:~ # cat /etc/locale.conf LANG=en_US.UTF-8
-
修改系统当前字符集
localectl set-locale LANG=zh_CN.UTF-8
或者直接修改/etc/locale.conf配置文件
[09:58:54] root@ive:~ # echo LANG=zh_CN.UTF-8 > /etc/locale.conf
-
重启系统生效,或者使用source临时生效
source /etc/locale.conf