在我的裸centos6.5系统中,它是一个docker
容器,en_US.utf-8
缺少语言环境:
bash-4.1# locale -a
C
POSIX
通常在 Ubuntu 中有命令locale-gen
可以执行此操作:
# locale-gen en_US.UTF-8
# echo 'LANG="en_US.UTF-8"' > /etc/default/locale
我怎样才能在centos 6.5中做到这一点?
答案1
locale-gen
不存在于Centos/Fedora
.
您必须使用localedef
:
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
从man localedef
:
NAME
localedef - define locale environment
SYNOPSIS
localedef [-c][-f charmap][-i sourcefile][-u code_set_name] name
DESCRIPTION
The localedef utility shall convert source definitions for locale cate‐
gories into a format usable by the functions and utilities whose opera‐
tional behavior is determined by the setting of the locale environment
variables defined in the Base Definitions volume of
IEEE Std 1003.1-2001, Chapter 7, Locale. It is implementation-defined
whether users have the capability to create new locales, in addition to
those supplied by the implementation. If the symbolic constant
POSIX2_LOCALEDEF is defined, the system supports the creation of new
locales. On XSI-conformant systems, the symbolic constant
POSIX2_LOCALEDEF shall be defined.
答案2
我根据@Gnouc 的回答提供了额外的信息(localedef
将在 centos 中使用)
这centos docker
是一个提供最小包的特殊图像,请参阅脚本https://github.com/dotcloud/docker/blob/master/contrib/mkimage-yum.sh
rm -rf "$target"/usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive}
内部命令localedef
被删除,glibc-common
包含该命令的软件包应重新安装
yum reinstall glibc-common
尺寸肯定会增加