centos6中的locale-gen命令


17

在我的裸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中执行此操作?

Answers:


32

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.

谢谢,yum whatprovides */localedef报告glibc-common包,但/usr/bin/localedef不存在。奇怪,因为码头工人?
larrycai 2014年

@larrycai:我不确定,以前没有见过这个问题。结果如何ldd /usr/bin/localedef
cuonglm

该文件不存在,只有locale命令。如果您认识docker,也可以docker run -i -t centos bash进行检查。
larrycai 2014年

谢谢您,先生〜我对那些奇怪的字符感到非常恼火:)
Eddie B

8

我根据答案@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

尺寸肯定会增加


yum reinstall glibc-common在Amazon Linux 2.17-196.172.amzn1Docker容器(hub.docker.com/r/ambakshi/amazon-linux)上为我提供了localedef,并允许我安装了elixir。
凯文·约翰逊
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.