Linux Internationalization HOWTO By davidjo@student.matnat.uio.no

By | 06/09/2011

Linux Internationalization HOWTO By davidjo@student.matnat.uio.no

What do you do when you want your Linux box to talk to you in Japanese, Korean, Norwegian, English and possibly some Swedish? How about inputting foreign alphabets? As with anything else in Linux it doesn’t quite work straight out of the box, but in this howto I’ll try to explain how to get it working at least half-decently.


Using Linux in your native language
 The C library
Input methods
 IBus – Intelligent Input Bus for Linux / Unix OS
 Smart Common Input Method
 Universal Input Method
The UTF-8 text encoding
Contact details

Using Linux in your native language

Though I personally hate seeing improvised Norwegian translations of popular English computer terms, a lot of people find it easier to use Linux in their native language.

Although localization settings for software like Gnome or KDE may be altered simply by using a control panel, users of other software solutions may need to change some settings called environment variables. The names of these variables begin with LC_, and LC_CTYPE should be the most important one for enabling input methods. Additionally, LANG and in some cases LANGUAGE might be needed to change the language in some programs.

The C library

Support for these settings relies on the C library having support for them compiled in. If it isn’t there and you’re desparate to have localization support outside of Gnome and KDE, you may want to recompile your C library with foreign language support. This will take quite a while, so sit down with your favorite manga (or manhwa) and a good cup of coffee.

(On Gentoo Linux, if support for locales has been compiled in, the USE flag nls should be found in your /etc/make.conf file. If it isn’t there, add nls to the USE flag section and emerge glibc again.)

Changing the environment variables involves finding the code for your language and country using the command line. First, run the command locale -a and find the appropriate code for your language and country in the list. Try Google if you’re unsure of which one it is.

The system language then needs to be set by a script that runs every time the system starts up. On Gentoo Linux, the correct file is apparently called /etc/env.d/02locale. For a lot of systems, though, a quick and alomst certainly incorrect way is to enter the necessary codes into the startup script which runs near the very end of the bootup procedure, and which may be called rc.local. Assuming that our language of choice is the beautiful “Example Language”, the code might be as follows:

export LC_CTYPE=example_LANGUAGE
export LANG=example_LANGUAGE
export LANGUAGE=example_LANGUAGE 

Et voila. Upon rebooting your machine a lot of applications should start appearing in the language of your choice.

Another neat feature is the ability to run just one program in another language without changing your settings. Simply specify the variables before your program name on a command line:

LANG=example_LANGUAGE LC_CTYPE=example_LANGUAGE LANGUAGE=example_LANGUAGE my_program

Input methods

Although most text input is carried out simply by using a certain keyboard layout (Like an American one or a Norwegian one), some languages require the user to use a special input method for entering text. These often work by transliterating the text that the user is entering from the Latin alphabet to some other script, like Hiragana or Traditional Chinese.

There are currently three important implementations of input methods on Unix-like systems: The traditional X Input Method interface (XIM), and two types of input modules particular to the GTK2 and Qt libraries.

This howto deals with three software packages that support all three of these interfaces, as well as a wide range of languages: IBus, SCIM and UIM.

IBus – Intelligent Input Bus for Linux / Unix OS

IBus is an input method framework that aims to support the same broad range of input methods and languages as SCIM, mentioned below, but with a different internal mechanism based on dbus and Python.

The first necessary step is installing IBus itself, and the GTK2 immodule and Qt immodule interfaces which allow it to interface with GTK2- and Qt-based applications.

Input methods must also be installed separately. Here are some notable input methods:

ibus-pinyin: Chinese input via a smart pinyin method. ibus-pinyin supports smart pinyin input for both Simplified and Traditional Chinese.
ibus-anthy: Japanese input.
ibus-hangul: Korean input. ibus-hangul supports romanized Korean as well as standard Korean keyboard layouts. A special mode for quick input of hanja is also supported.
ibus-m17n: Various input methods using libm17n, a multilingual text processing library.

If you have GTK2, you might need to run the following command after the installation:

update-gtk-immodules 

Or alternatively:

gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules 

On the newest versions of Ubuntu Linux, a lot of the IBus configuration is done automatically, so I haven’t investigated thoroughly how to cause IBus to start automatically, work with XIM, or become the default input method in Qt or GTK2. However, placing the following line in your ~/.xinitrc file ought to cause IBus to start whenever you start X:

/usr/bin/ibus-daemon --xim &

Adding the following lines to ~/.xinitrc ought to make IBus the default input method:

export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS="@im=ibus" 

In most GTK2 and some Qt programs you’ll be able to select IBus by right-clicking on a text input field without using any special setup, if it isn’t already the default:

Selecting an input method in GTK. Selecting an input method in Qt.

To activate IBus, make sure the IBus daemon (ibus-daemon) is running, and press control + space. You should now see a menu in the bottom right corner of your screen where you can choose between several input methods. There should also be a menu option to hide the IBus panel, which some users prefer not to have on their screen. Alt + Left shift can be used to switch between input methods.

The IBus web site can be found at http://code.google.com/p/ibus/.

Smart Common Input Method

Smart Common Input Method is a multilingual input method framework that can be used both through the old X Input Method interface and as a module for GTK2 or Qt.

The first step is installing SCIM and any input methods you might need. Make sure to also install the GTK2 immodule and Qt immodule interfaces.

Some notable input methods:

scim-pinyin: Smart pinyin input. scim-pinyin is mainly for Simplified Chinese, but is somewhat useful for Tradtional Chinese.
scim-anthy: Japanese input.
scim-hangul: Korean input. Users wanting to input romanized Korean will want to install scim-m17n.
scim-m17n: Various input methods using libm17n, a multilingual text processing library.

If you have GTK2, you might need to run the following command after the installation:

update-gtk-immodules

Or alternatively:

gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules

SCIM needs a backend application to make it work with applications that don’t use GTK2 or Qt. If you need this functionality, it’s a good idea to start it whenever you start X, so put the following command line somewhere before the last command in your ~/.xinitrc:

scim -d

To make SCIM your default input method, go back to your ~/.xinitrc and add the following lines:

export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE="scim"
export QT_IM_MODULE=scim 

By davidjo@student.matnat.uio.no

ที่มา: http://folk.uio.no/davidjo/languages.php

One thought on “Linux Internationalization HOWTO By davidjo@student.matnat.uio.no

ใส่ความเห็น