web.onassar.com Archive

I can be reached at onassar@gmail.com.

For my open source work, check out github.com/onassar

Adding a language package (french) to Ubuntu Linux (10.10)

View more posts

Working on a new project whereby we're using PHP's money formatting (see PHP money_format), we ran into an issue whereby the money wasn't being formatted properly for french users.

Specifically, the period between the dollar and hundredth-dollar numbers is replaced by a comma. In order for this to be managed automatically by the function, the setlocale function needs to be called as follows:

setlocale(LC_MONETARY, 'fr_CA.UTF-8');

While the first argument could be the constant LC_ALL, in this case we simply wanted the monetary functions to be formatted properly (eg. we're not following the larger-standard for internationalization/i18n). I made a pretty silly and invalid assumption that that was all it would take, but alas, the operating system didn't have that language package installed. I believe it comes with the english set by default on a fresh install, but not french.

Here were the steps I followed to get the french packages on the server:

sudo apt-get -y install language-pack-en
sudo locale-gen fr_CA.UTF-8
sudo dpkg-reconfigure locales
sudo vi /etc/default/locale
sudo reboot

When editing the /etc/default/locale file, I simply added in the following line at the end of the file:


After the reboot, the language file for Canadian french (in the UTF-8 encoding, by the way), is included and ready to use.