This is an old revision of the document!


Locales in Ubuntu-based dCore

In Ubuntu, locales are created based on language packs. Proper locale files are generated by locale-gen. Since these files are large, making them persistent is best done by creating a locale extension.

Preparation

Import and load the locales package.

Review '/usr/share/i18n/SUPPORTED' for a list of locales to determine the desired locale code.

Comment out the line in '~/.profile' that hard codes LANG to “en_US.UTF-8”:

~/.profile:
#LANG=en_US.UTF-8

Use the lang boot code instead (eg. lang=de_CH.UTF-8 for Swiss German locale).

For a first test locale will complain that it cannot set some LC_ variables but will then list where all but LANGUAGE and LC_ALL are set to the chosen locale code.

Fallback Locales

International users may want US English as a fallback to be stored in LANGUAGE (source: Archlinux-wiki). If so, add the following to '~/.profile':

~/.profile:
LANGUAGE=$LANG:en_US.UTF-8:en

Generating Locale Files

Create a temporary working directory (eg. ~/temp/).

Create a package list in (eg. ./mylocale.lst) with all desired language choices (eg. English and German):

./mylocale.lst:
coreutils
bash
libc-bin
language-pack-en
language-pack-de

Import the package list using sce-import -n -l ./mylocale.lst and load them.

Run sudo locale-gen –archive (double dash before 'archive') to produce '/usr/lib/locale/locale-archive' containing all locales specified in the language packs.

Testing

locale will show the same list as before without errors. Furthermore date +%A will print the week-day in the local language.

Package Selection

The language packs depend on the locale package, which provides the command locale-gen. This is a Bash script which uses the core-utilities plus 'localedef' which is not included in locale but rather in libc-bin.

Create a Locales Extension

Certainly, one could add “usr/lib/locale/locale-archive” to '.filetool.lst' to make the locales archive persistent. However, the archive is approximately 2 MB in size per language and (un-)packing such a file at each boot or shutdown, respectively, takes considerable time.

Since the archive will not change (unless one should have reason to update it) it is futile to have it included in the backup process. Let's create therefore an extension containing that single file!

In the temporary directory, create a directory that contains the full path to the archive and move that one in there.

mkdir -p ./mylocale/usr/lib/locale/
sudo mv /usr/lib/locale/locale-archive ./mylocale/usr/lib/locale/

The directory is packed into a SquashFS-file, that is an extension. That extension is then put in the right place.

mksquashfs ./mylocale/ mylocale.sce
sudo mv mylocale.sce /etc/sysconfig/tcedir/sce/

Finally, create a file containing the MD5-sum of that extension because that is needed especially by sce-update.

md5sum /etc/sysconfig/tcedir/sce/mylocale.sce > /etc/sysconfig/tcedir/sce/mylocale.sce.md5.txt

Optionally, the extension is included into 'sceboot.lst' so as to have it automatically loaded at boot.

Testing

After rebooting locale should list all LC-variables set to the chosen locale code.

Cleanup

The extensions locales and mylocale.lst can be removed together with the temporary directory.

> Return to the dCore Wiki Welcome page

Print/export
QR Code
QR Code dcore:locale_in_ub-dcore (generated for current page)