Thursday, April 06, 2006

en_CH locale

English may not be one of the official Swiss languages (yet?), but it is certainly useful in a computer system. I don't want server logs and error messages in French or German or Italian (or Romantsch?). These things are easiest to understand and get help about in English. But I don't want dates in the confusing US "MM/DD/YY" format either, or times in AM/PM. Most importantly: I want sorting to work correctly with accented letters, and I want Perl to understand accented letters for \w, the uc(), lc() functions, etc.

So I made my own en_CH locale. Tested it in Debian stable (3.1 "Sarge"), and it seems to do what I expected. If you want to try it out, the steps are below. And it is quite easy to edit language_COUNTRY files to suit your needs.
# cp /usr/share/i18n/SUPPORTED /usr/share/i18n/SUPPORTED.orig
# echo -e "en_CH ISO-8859-1\nen_CH.UTF-8 UTF-8" | sort - /usr/share/i18n/SUPPORTED.orig >/usr/share/i18n/SUPPORTED
# wget -O /usr/share/i18n/locales/en_CH
# echo "en_CH ISO-8859-1" >>/etc/locale.gen
# echo "en_CH.UTF-8 UTF-8" >>/etc/locale.gen
# dpkg-reconfigure locales
You may also need to edit your /etc/environment file and/or /etc/default/locale if they have a left-over LANGUAGE= line.
At your next login, your locale should be set to en_CH, and these little tests should work:
$ echo -e "é\ne\nA\nà\nE" |sort
$ perl -Mlocale -e 'print "Uppercase accented é and à: ", uc("éà\n")'
$ echo -e "é\ne\nA\nà\nE" |perl -Mlocale -ne 'while (/(\w+)/g) {print "$1\n"}'
(Note that for Perl, you need use locale;).

Update: For Ubuntu 6.10 ("Edgy"), see also this post in this ubuntu forum thread!

Labels: , , , , , ,


Blogger Ayberk Özgür said...

Thanks a lot! On Ubuntu 14.04, I ran `locale-gen en_CH.UTF-8` instead of listing it in `/etc/locale.gen` which I think is not used anymore.

17 June, 2014 09:53  
Blogger Ayberk Özgür said...

This comment has been removed by the author.

17 June, 2014 09:54  

Post a Comment

Links to this post:

Create a Link

<< Home