如何在CentOS 7上(在Docker上)添加语言支持?


10

我正在尝试将语言环境设置为日语,但是docker上的CentOS映像不包含语言支持。

bash-4.2# yum groupinstall -y "Japanese Support"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: centos.mirror.secureax.com
 * updates: centos.mirror.secureax.com
Warning: group Japanese Support does not exist.
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update

我已经检查了群组列表yum grouplistyum grouplist hidden并且都不包含日语支持。
有什么方法可以安装日语支持?
提前致谢。

Answers:


11

我在RHEL 7.4 docker映像中遇到了相同的问题。yum reinstall glibc-common本身并不能解决问题。它只是安装英语。

我在docker容器/etc/yum.conf中发现该行override_install_langs=en_US。这导致yum reinstall glibc-common只安装英语。

将此行注释掉(或更改为所有默认值),然后重新运行,yum reinstall glibc-common我便可以使用其他语言

docker运行/附加后的初始环境

# locale -a
C
POSIX
en_US.utf8
# grep lang /etc/yum.conf
override_install_langs=en_US
# export LANG=fr_FR
# ls foo
ls: cannot access foo: No such file or directory

我尝试在更改之前重新安装glib-common /etc/yum.conf

# yum -y -q reinstall glibc-common
Failed to set locale, defaulting to C
# ls foo
ls: cannot access foo: No such file or directory
# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
#

更改/etc/yum.conf后注释掉该行override_install_langs=en_US

# vi /etc/yum.conf
# grep lang /etc/yum.conf
#override_install_langs=en_US
# yum -y -q reinstall glibc-common
Failed to set locale, defaulting to C
# ls foo
ls: cannot access foo: Aucun fichier ou dossier de ce type
# locale -a | wc -l
789

1

您需要重新安装该glibc-common软件包。这是证明:

docker run -it --rm centos bash -c 'locale -a | wc -l && yum -y -q reinstall glibc-common && locale -a | wc -l'
53
789

注意:locale -a列出已安装的语言环境并进行wc -l计数,因此这些数字是重新安装之前和之后的语言环境数glibc-common


0

我有类似的问题,因为CentOS映像没有安装语言包。我安装了glibc-langpack-en软件包来获得en支持。所以我想你需要glibc-langpack-ja

yum install glibc-langpack-ja
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.