# Problems with locales

## tkhobbes

Hi there

I was not sure where to post this, so feel free to move...  :Smile: 

Anyway, I have some problems with my locales; I wanted to migrate to UTF-8, as written in this superb doc: http://www.gentoo.org/doc/en/utf-8.xml.

I want to have an "en_US.UTF-8" locale, but here's the outputs I get:

```

thomas@linux ~ $ locale -a | grep 'en_US'

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

thomas@linux ~ $ sudo localedef -i en_US -f UTF-8 en_US.UTF-8

cannot read character map directory `/usr/share/i18n/charmaps': No such file or directory

```

What's wrong?

thanks

thomas

----------

## tkhobbes

Anyone?

 :Embarassed: 

----------

## morodoch

I followed the howto on the wiki:

```
http://gentoo-wiki.com/HOWTO_Create_an_UTF-8_enabled_system
```

It worked for en_GB, so it may work for en_US  :Smile: 

----------

## Cintra

do you have this in:

```
# cat /etc/locales.build

# This file names the list of locales to be built when glibc is installed.

# The format is <locale>/<charmap>, where <locale> is a locale from the

# /usr/share/i18n/locales directory, and <charmap> is name of one of the files

# in /usr/share/i18n/charmaps/. All blank lines and lines starting with # are

# ignored. Here is an example:

# en_US/ISO-8859-1

en_US/ISO-8859-1

en_US.UTF-8/UTF-8

```

and

```
# cat /etc/env.d/02locale

LC_ALL="en_US.utf8"

```

and do you have the userlocales USE flag for glibc?

and finally do you have the /usr/share/i18n/charmaps directory?

Mvh

----------

## morodoch

```
% cat /etc/locales.build 

# This file names the list of locales to be built when glibc is installed.

# The format is <locale>/<charmap>, where <locale> is a locale from the

# /usr/share/i18n/locales directory, and <charmap> is name of one of the files

# in /usr/share/i18n/charmaps/. All blank lines and lines starting with # are

# ignored. Here is an example:

# en_US/ISO-8859-1

en_US/ISO-8859-1

en_US.UTF-8/UTF-8

ja_JP.EUC-JP/EUC-JP

ja_JP.UTF-8/UTF-8

ja_JP/EUC-JP

en_HK/ISO-8859-1

en_PH/ISO-8859-1

de_DE/ISO-8859-1

de_DE@euro/ISO-8859-15

es_MX/ISO-8859-1

fa_IR/UTF-8

fr_FR/ISO-8859-1

fr_FR@euro/ISO-8859-15

it_IT/ISO-8859-1

en_GB/ISO-8859-1

en_GB.UTF-8/UTF-8

```

```
% cat /etc/env.d/02locale 

LANG="en_GB.utf8"

LANGUAGE="en_GB.utf8"

LC_ALL="en_GB.utf8"

```

```
# emerge -pv glibc

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] sys-libs/glibc-2.3.5-r2  -build -erandom -glibc-compat20 -glibc-omitfp -hardened -linuxthreads-tls (-multilib) +nls +nptl -nptlonly +pic -profile (-selinux) +userlocales 0 kB 

```

```
# ls -ld /usr/share/i18n/charmaps

drwxr-xr-x  2 root root 7048 Dec  4 12:08 /usr/share/i18n/charmaps

```

HTH

----------

## tkhobbes

Thanks for this; I adapted everything to my needs, so here's my /etc/locales.build:

```

de_CH.UTF-8/UTF-8

en_US.UTF-8/UTF-8

en_US/ISO-8859-1

de_DE@euro/ISO-8859-15

```

Here's my /etc/env.d/02locale:

```

LANG="en_US.utf8"

LANGUAGE="en_US.utf8"

LC_ALL="en_US.utf8"

```

And here's the output of emerge -pv glibc:

```

[ebuild   R   ] sys-libs/glibc-2.3.5-r2  +build -erandom -glibc-compat20 -glibc-omitfp -hardened -linuxthreads-tls (-multilib) +nls -nptl -nptlonly -pic -profile (-selinux) +userlocales 0 kB

```

Now, I re-emerged glibc, but when issueing the last command, ls -ld /usr/share/i18n/charmaps, I get this:

```

ls: /usr/share/i18n/charmaps: No such file or directory

```

 :Sad: 

EDIT: I also saw the output of some glibc-emerge task:

```
>>> original instance of package unmerged safely.

//usr/sbin/iconvconfig: cannot open `//usr/lib/gconv/gconv-modules': No such file or directory

//usr/sbin/iconvconfig: no output file produced because warning were issued

```

I don't know what this means, as it is at the end of the emerge and it did not return an error...

thomas

----------

## Cintra

the difference between your emerge -vp glibc and mine seems to be +nptl:

```
# emerge -pv glibc

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] sys-libs/glibc-2.3.5-r2  USE="-build -erandom -glibc-compat20 -glibc-omitfp -hardened -linuxthreads-tls +nls +nptl -nptlonly -pic -profile +userlocales" 0 kB
```

 *Quote:*   

> nptl Enable support for Native POSIX Threads Library, the new threading module (requires linux-2.6 or better usually)

 btw, adding nptl to your make.conf USE flags will result in glibc being emerged twice each time.

Though I'm not 100% sure that is your problem. Do you also have unicode in your USE flags?

Mvh

Edit: what kernel are you using?

Oh, and another thing +build? where did that come from?

 *Quote:*   

> build  !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping

 

----------

## tkhobbes

Added nptl, re-emerged, nothing changed.

I don't know where the build comes from; I now explicitily excluded it via "-build" in /etc/make.conf (however, it still showes up when issueing "emerge -pv glibc" - there is still a +build....)

Kernel-Version is 2.6.14-gentoo-r5

thomas

----------

## Cintra

there is possibly a shorter solution but I know what I would do in your place..

rebuild the toolchain and do an 'emerge -e system' 

...after taking a full backup of course!

 :Wink: 

Edit: could be an idea to list your 'emerge info' here as someone else may notice something.

Have you a copy of emwrap http://www3.telus.net/dol-sen/linux/

That would simplify toolchain rebuilding with for example 'emwrap -pet'

----------

## morodoch

I don't understand this, the /usr/share/i18n/charmaps directory definitely was installed by my glibc emerge. I don't know if this helps, but you can build the locales files after installing glibc, see here:

http://www.tldp.org/LDP/lfs/html/chapter05/glibc.html

----------

## tkhobbes

The page from LFS is neat - but the localedef command does not work:

```

linux ~ # localedef -i en_US -f UTF-8 en_US.UTF-8

cannot read character map directory `/usr/share/i18n/charmaps': No such file or directory

```

Here's my emerge info:

```

Portage 2.0.51.22-r3 (default-linux/x86/2005.0, gcc-3.3.6, glibc-2.3.5-r2, 2.6.14-gentoo-r2 i686)

=================================================================

System uname: 2.6.14-gentoo-r2 i686 Intel(R) Celeron(R) CPU 2.40GHz

Gentoo Base System version 1.6.13

distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]

dev-lang/python:     2.3.5-r2, 2.4.2

sys-apps/sandbox:    1.2.12

sys-devel/autoconf:  2.13, 2.59-r6

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1

sys-devel/binutils:  2.16.1

sys-devel/libtool:   1.5.20

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=pentium4"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"

CXXFLAGS="-O2 -march=pentium4"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks sandbox sfperms strict"

GENTOO_MIRRORS="http://gentoo.mirror.solnet.ch http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://pandemonium.tiscali.de/pub/gentoo/ http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="x86 a52 aac aalib acpi alsa apache2 apm audiofile avi bash-completion berkdb bitmap-fonts bzip2 bzlib cdda cdr crypt cups curl dvd eds emboss encode exif expat fbcon ffmpeg flac foomaticdb fortran ftp gd gdbm gif gmp gpm gstreamer httpd imagemagick imap imlib ipv6 jpeg ldap libg++ libwww mad maildir math mhash mikmod mime mmx mp3 mpeg mysql ncurses nls nptl ogg oggvorbis pam pcre pdflib perl php png ppds python quicktime readline samba sasl scanner sdl spell ssl svga symlink tcpd tetex tidy tiff truetype truetype-fonts type1-fonts udev unicode usb userlocales vcd vlm vorbis xml xml2 xsl xvid zlib userland_GNU kernel_linux elibc_glibc"

Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTDIR_OVERLAY

```

----------

## Cintra

I wonder if this can be a kernel problem.. I have this (edited) in my .config file

```
#

# Native Language Support

#

CONFIG_NLS=y

CONFIG_NLS_DEFAULT="iso8859-1"

CONFIG_NLS_CODEPAGE_437=y

# CONFIG_NLS_CODEPAGE_737 is not set

# CONFIG_NLS_CODEPAGE_775 is not set

CONFIG_NLS_CODEPAGE_850=m

# CONFIG_NLS_CODEPAGE_852 is not set

...

# CONFIG_NLS_CODEPAGE_864 is not set

CONFIG_NLS_CODEPAGE_865=m

# CONFIG_NLS_CODEPAGE_866 is not set

...

# CONFIG_NLS_CODEPAGE_874 is not set

# CONFIG_NLS_ISO8859_8 is not set

# CONFIG_NLS_CODEPAGE_1250 is not set

# CONFIG_NLS_CODEPAGE_1251 is not set

CONFIG_NLS_ASCII=m

CONFIG_NLS_ISO8859_1=y

# CONFIG_NLS_ISO8859_2 is not set

...

# CONFIG_NLS_ISO8859_14 is not set

CONFIG_NLS_ISO8859_15=y

# CONFIG_NLS_KOI8_R is not set

# CONFIG_NLS_KOI8_U is not set

CONFIG_NLS_UTF8=y
```

How does that compare?

----------

## tkhobbes

Here is the part from my config-file:

```

CONFIG_NLS=y

CONFIG_NLS_DEFAULT="iso8859-1"

# CONFIG_NLS_CODEPAGE_437 is not set

# CONFIG_NLS_CODEPAGE_737 is not set

# CONFIG_NLS_CODEPAGE_775 is not set

CONFIG_NLS_CODEPAGE_850=y

# CONFIG_NLS_CODEPAGE_852 is not set

# CONFIG_NLS_CODEPAGE_855 is not set

# CONFIG_NLS_CODEPAGE_857 is not set

# CONFIG_NLS_CODEPAGE_860 is not set

# CONFIG_NLS_CODEPAGE_861 is not set

# CONFIG_NLS_CODEPAGE_862 is not set

# CONFIG_NLS_CODEPAGE_863 is not set

# CONFIG_NLS_CODEPAGE_864 is not set

# CONFIG_NLS_CODEPAGE_865 is not set

# CONFIG_NLS_CODEPAGE_866 is not set

# CONFIG_NLS_CODEPAGE_869 is not set

# CONFIG_NLS_CODEPAGE_936 is not set

# CONFIG_NLS_CODEPAGE_950 is not set

# CONFIG_NLS_CODEPAGE_932 is not set

# CONFIG_NLS_CODEPAGE_949 is not set

# CONFIG_NLS_CODEPAGE_874 is not set

# CONFIG_NLS_ISO8859_8 is not set

# CONFIG_NLS_CODEPAGE_1250 is not set

# CONFIG_NLS_CODEPAGE_1251 is not set

# CONFIG_NLS_ASCII is not set

CONFIG_NLS_ISO8859_1=y

# CONFIG_NLS_ISO8859_2 is not set

# CONFIG_NLS_ISO8859_3 is not set

# CONFIG_NLS_ISO8859_4 is not set

# CONFIG_NLS_ISO8859_5 is not set

# CONFIG_NLS_ISO8859_6 is not set

# CONFIG_NLS_ISO8859_7 is not set

# CONFIG_NLS_ISO8859_9 is not set

# CONFIG_NLS_ISO8859_13 is not set

# CONFIG_NLS_ISO8859_14 is not set

# CONFIG_NLS_ISO8859_15 is not set

# CONFIG_NLS_KOI8_R is not set

# CONFIG_NLS_KOI8_U is not set

CONFIG_NLS_UTF8=y

```

I think it is ok...

----------

## Cintra

It looks ok to me but if you want utf-8 you need to change the value of this line to 

```
CONFIG_NLS_DEFAULT="utf8"
```

and the usual 'make && make modules_install' etc.

mvh

----------

## morodoch

 *Quote:*   

> linux ~ # localedef -i en_US -f UTF-8 en_US.UTF-8
> 
> cannot read character map directory `/usr/share/i18n/charmaps': No such file or directory 

 

This is *really* weird - this directory was also installed by my emerge of glibc. I don't understand how we could have almost the same USE flags and I end up with a couple of system directories you don't have. (The nptl is for threading, and nothing to with NLS AFAIK.)

As far as the kernel config goes, you'll need to do this to get utf8 in your filesystems, I think, but I don't think it should affect your userspace stuff - unless glibc is a special case?

Curiouser and curiouser...

----------

## tkhobbes

I have another gentoo box (a client, the one having problems is really a server) - could I just copy the missing directory over?

----------

## morodoch

I don't really know, but it could be worth a try - the files don't *look* architecture specific.

----------

