01 December 2008

Making locales available without .UTF8 appendix on Ubuntu

In Ubuntu locales are added via

apt-get install language-pack-en-base

Where en is the langcode.
By default locales are added with UTF-8 encoding, and are available to the system via nl_NL.UTF-8 or en_US.UTF-8.

In some environments, PHP coms to mind, this UTF-8 appendix isn't really common. We want to be able to access a local via the langcode only.
To make this possible you have to do the following:

Edit /var/lib/locales/supported.d/ (in this example we'll use nl)
Add a line for each langcode without the .UTF-8 appendix, but leav te UTF-8 after the space intact. The file for nl will look like this when we're done:

nl_BE.UTF-8 UTF-8
nl_BE UTF-8
nl_NL.UTF-8 UTF-8
nl_NL UTF-8

Recreate the locales with:
locale-gen --purge

The locales are now available to the system without the UTF-8 extention.

No comments: