locale-gen command in centos6

51,371

Solution 1

locale-gen is not present in Centos/Fedora.

You must use localedef:

localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

From 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.

Solution 2

I provided extra information based on answer @Gnouc (localedef shall be used in centos)

The centos docker is a special image which provides minimal packages, see script 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}

Inside command localedef is removed, glibc-common package which include this shall be reinstalled

yum reinstall glibc-common

surely the size will be increased

Share:
51,371

Related videos on Youtube

larrycai
Author by

larrycai

Updated on September 18, 2022

Comments

  • larrycai
    larrycai over 1 year

    In my bare centos6.5 system, which is a docker container, en_US.utf-8 locale is missing:

    bash-4.1# locale -a
    C
    POSIX
    

    Normally in Ubuntu there is command locale-gen to do this:

    # locale-gen en_US.UTF-8
    # echo 'LANG="en_US.UTF-8"' > /etc/default/locale
    

    How can I do this in centos 6.5?

  • larrycai
    larrycai almost 10 years
    thank, yum whatprovides */localedef reports for glibc-common package, while /usr/bin/localedef doesn't exist. strange, because of docker ?
  • cuonglm
    cuonglm almost 10 years
    @larrycai: I'm not sure, haven't seen this problem before. What result ldd /usr/bin/localedef.
  • larrycai
    larrycai almost 10 years
    the file doesn't exist, only locale command. If u know docker, you can run docker run -i -t centos bash to check as well.
  • Edward J Beckett
    Edward J Beckett over 8 years
    Thanks sir ~ I was getting quite annoyed by the odd chars :)
  • Kevin Johnson
    Kevin Johnson over 6 years
    yum reinstall glibc-common made localedef available for me on Amazon Linux 2.17-196.172.amzn1 Docker container: hub.docker.com/r/ambakshi/amazon-linux and allowed me to get elixir installed.
  • devstructor
    devstructor over 2 years
    It didn't work for me in ubi8 out of the box. To make it work you have to install glibc-locale-source package. Otherwise localedef will complain: [error] character map file UTF-8 not found: No such file or directory