Trac complains about "unknown encoding: utf_8_euro" (fixed)

Printer-friendly versionPrinter-friendly version
Trac Logo

I recently had problems with a new-installed Trac that complains about:
LookupError: unknown encoding: utf_8_euro

This problem occurs when using a locale such as it_IT.UTF-8@euro, due to a wrong use of the python function:
locale.getdefaultlocale()[1]
that fails with such locales. While the recommended way to fix that is to use the locale.getpreferredencoding() function instead, a way to fix it is to set the environment variables defining the locale to something safer, such as en_US.UTF-8, or just it_IT.UTF-8.

To set the default locale on Gentoo, just edit the /etc/profile.env file:
Old version:

1
2
3
4
5
6
7
8
9
10
11
12
13
export LANG='en_US.UTF-8'
export LC_ADDRESS='it_IT.UTF-8@euro'
export LC_COLLATE='it_IT.UTF-8@euro'
export LC_CTYPE='it_IT.UTF-8@euro'
export LC_IDENTIFICATION='it_IT.UTF-8@euro'
export LC_MEASUREMENT='it_IT.UTF-8@euro'
export LC_MESSAGES='en_US.UTF-8'
export LC_MONETARY='it_IT.UTF-8@euro'
export LC_NAME='it_IT.UTF-8@euro'
export LC_NUMERIC='it_IT.UTF-8@euro'
export LC_PAPER='it_IT.UTF-8@euro'
export LC_TELEPHONE='it_IT.UTF-8@euro'
export LC_TIME='it_IT.UTF-8@euro'

New version:

1
2
3
4
5
6
7
8
9
10
11
12
13
export LC_ADDRESS='en_US.UTF-8'
export LC_COLLATE='en_US.UTF-8'
export LC_CTYPE='en_US.UTF-8'
export LC_IDENTIFICATION='en_US.UTF-8'
export LC_MEASUREMENT='en_US.UTF-8'
export LC_MESSAGES='en_US.UTF-8'
export LC_MONETARY='en_US.UTF-8'
export LC_NAME='en_US.UTF-8'
export LC_NUMERIC='en_US.UTF-8'
export LC_PAPER='en_US.UTF-8'
export LC_TELEPHONE='en_US.UTF-8'
export LC_TIME='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'

Then, you could overwrite these settings using per-user .bash_profile.

Another way could be using per-host environment settings in the apache config (UNTESTED):

1
2
3
4
SetEnv LANG en_US.UTF-8
SetEnv LC_TIME en_US.UTF-8
SetEnv LC_ALL en_US.UTF-8
...

References

There is also a similar debian bug: http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thre...

2 comments

 
Anonymous wrote 5 weeks 1 day ago

spunk eva

hovel road eg mask direct auto insurance fyi tanks

 
Anonymous wrote 10 weeks 17 hours ago

hens

aches chic scrip vicky auto bestelle viagra pound motif puns lasix wv myopia stark

Who Am I?

~redShadow~ A.K.A. Samuele Santi is an Italian Open Source developer, currently working as a freelance developer, mainly in the web applications sector. Favourite programming languages: PHP and, of course, Python!

blogroll (7) Drupal Forms (1) algorythms (1) curl (1) blender (3) aircrack (1) database (3) 2v (1) apache (1) circuits (1) alcool (1) archive (1) contact manager (1) Drupal (21) cocktails (1) C++ (2) aoe (1) audio (1) debug (1) cartoons (1) debian (1) citroen (1) 3d (3) awstats (3) caos (1) cryptography (1) dmcrypt (1) documentation (2) doku (1) arduino (1) bash (11) camera mia (1) cars (1) e-mail (2) backup (3) apt (1) como lake rovers (1) development (11) code (3) address book (2)