Changing locales in Ubuntu PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Bart Dorlandt   
Tuesday, 12 January 2010 15:04

The following peace is copied from http://blog.bigsmoke.us/2009/06/16/adding-locales-in-ubuntu.

---------------------------

I wanted the dates on my Kubuntu system to be shown as Dutch dates. Therefore, I needed to add a locale. The place to do it is in /var/lib/locales/supported.d/local. It now contains this:

en_US.UTF-8 UTF-8
nl_NL.UTF-8 UTF-8

Then run locale-gen to generate the locales.

Set the following environment vars (in profile or something) to let everything behave properly:

export LANG="nl_NL.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_COLLATE="C"

I don’t know anymore why I chose this specific configuration. I guess this means that everything, from thousand and decimal separators to dates is Dutch, and messages are English. I don’t know, however, why the collate is C. I vaguely remember something about it otherwise not including some characters in the sorting, causing weird sorting in words with dashes and such.

---------------------------

I have created my own solution around it:

Because I have my profiles (of bash) within my SVN repository, I'm able to access them on all my machines (and others).

Because the export function only works correctly and without errors when the locales are specified my scripts make sure it exists. My root .bash_aliases has the following at the end of the file:

# add "nl_NL.UTF-8 UTF-8" to /var/lib/locales/supported.d/local
if [ ! "`cat /var/lib/locales/supported.d/local | grep 'nl_NL.UTF-8 UTF-8'`" == "nl_NL.UTF-8 UTF-8" ]; then
echo "nl_NL.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local
fi
export LANG="nl_NL.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_COLLATE="C"

So it will write to the file if it doesn't has the NL locale yet. After that the bash will do the exports.

For my normal user, my .bash_aliases has the following:

# add "nl_NL.UTF-8 UTF-8" to /var/lib/locales/supported.d/local
if [ '`cat /var/lib/locales/supported.d/local | grep "nl_NL.UTF-8 UTF-8"`' == 'nl_NL.UTF-8 UTF-8' ]; then
export LANG="nl_NL.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_COLLATE="C"
fi

It will check for the NL locale and if it exists it will export it.

Never have to worry about that again. Even after a re-install...

Trackback(0)
Comments (0)Add Comment

Write comment - Name & Email obligated

busy
 


Related items: