Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've written a web application for which the user interface is in Dutch. I use the system's date and time routines to format date strings in the application. However, the date strings that the system formats are in English but I want them in Dutch, so I need to set the system's locale. How do I do that on Debian? I tried setting LC_ALL=nl_NL but it doesn't seem to have any effect:

$ date
Sat Aug 15 14:31:31 UTC 2009
$ LC_ALL=nl_NL date
Sat Aug 15 14:31:36 UTC 2009

I remember that setting LC_ALL on my Ubuntu desktop system works fine. Do I need to install extra packages to make this work, or am I doing it entirely wrong?

share|improve this question
    
is there a way to do this automatically based on the assigned ip address of the server? –  Scoop Oct 5 '12 at 3:49

5 Answers 5

up vote 28 down vote accepted

Edit /etc/default/locale and set the contents to:

LANG="nl_NL.UTF-8"

You can check which locales you currently have generated using:

# locale -a

You can generate more by editing /etc/locale.gen and uncommenting the lines for the locales that you want to enable. Then you can generate them by running:

# locale-gen

You can find a list of supported locales in /usr/share/i18n/SUPPORTED

There is more information available on the Debian wiki.

share|improve this answer
7  
/var/lib/belocs/list doesn't exist. You need to edit /etc/locale.gen or run dpkg-reconfigure locales instead. –  pgs Aug 16 '09 at 2:44
    
+1 this answer for describing locale-gen, but as per the previous comment, there's no such file as /var/lib/belocs/list on my system –  telent Jul 12 '11 at 19:52

None of these answers worked for me, on an LXC container installed with:

lxc-create -n sse-master -t download -n sse-master -- \
    -d debian -r jessie --arch i386

I always got the following output from locale-gen, i.e. not generating any locales (none listed):

$ sudo locale-gen
Generating locales (this might take a while)...
Generation complete.

Running dpkg-reconfigure locales and selecting some locales did not update /etc/locale.gen as I expected it to.

However, when I modified that file manually and uncommented the locales that I wanted, then locale-gen started working properly:

$ sudo locale-gen
Generating locales (this might take a while)...
  en_GB.UTF-8... done
  en_US.UTF-8... done
Generation complete.

I was also able to generate locales manually like this:

sudo localedef -i en_US -f UTF-8 en_US.UTF-8
sudo localedef -i en_GB -f UTF-8 en_GB.UTF-8

But this was not a permanent solution: I found that running locale-gen without the --keep-existing option will delete all such manually-generated locales, i.e. every locale not listed (and uncommented) in /etc/locale.gen.

share|improve this answer

But first you need to have needed language pack installed. On my German based VPS there was no english language pack pre-installed. So first you check that you have it installed:

aptitude install language-pack-en
share|improve this answer

You may need to install the locales package. This will ask you which locales to generate. If it's already installed, then dpkg-reconfigure locales will let you generate more locales.

share|improve this answer
    
That only generates locales, not set the system default. –  David Pashley Aug 15 '09 at 15:54
10  
NO, the final question of dpkg-reconfigure locales is to select the default locale. –  pgs Aug 16 '09 at 2:42

For a web application, it might be better to use setlocale() inside the program, rather than requiring that the system default locale be set appropriately outside. Less loose ends that way.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.