Differences between revisions 40 and 41
Revision 40 as of 2008-05-03 16:41:05
Size: 13157
Editor: OsamuAoki
Comment:
Revision 41 as of 2008-05-03 16:42:05
Size: 13174
Editor: OsamuAoki
Comment:
Deletions are marked like this. Additions are marked like this.
Line 120: Line 120:
<!> The date format of {{{ls}}}(1) is affected by the locale and "{{{LANG=C ls -l}}}" and "{{{LANG=en_US.UTF-8}}}" are different. <!> The date format of {{{ls}}}(1) is affected by the locale.  The date format of "{{{LANG=C ls -l}}}" and "{{{LANG=en_US.UTF-8}}}" are different.

Do not use Edit(GUI) button.

?TableOfContents(4)

Copyright 2007 Osamu Aoki GPL, (Please agree to GPL, GPL2, and any version of GPL which is compatible with DSFG if you update any part of wiki page)

The I18N and L10N

The international support for the application software is done in 2 steps:

  • Multilingualization (m17n): To make software independent of the particular locale.
  • Localization (l10n): To configure multilingualized software to the particular locale.

Here, I18N stands for "internationalization" and L10N stands for "localization". (There are 18 and 10 letters between I and N or L and N.)

The modern software such as Gnome and KDE which are written to handle [http://en.wikipedia.org/wiki/UTF-8 UTF-8 ]data and to provide their message through the gettext(1) infrastructure are multilingualized and can be localized simply by setting pertinent environment variables to the appropriate locale if the corresponding translated message packages are installed.

The simplest representation of the text data is ASCII which is sufficient for English and uses less than 127 characters (representable with 7 bits). In order to support much more characters for the international support, many character encoding systems have been invented. The modern and sensible encoding system is UTF-8 which can handle practically all the characters known to the human (see: @{@basicsofencoding@}@).

The international hardware support is enabled with localized hardware configuration data.

The keyboard input

The Debian system can be configured to work with many international keyboard arrangements:

List of keyboard reconfiguration methods.

environment

command

Linux console

dpkg-reconfigure --priority=low console-data

X Window

dpkg-reconfigure --priority=low xserver-xorg

This will support keyboard input for accented characters of many European languages with its dead-key function. For Asian languages, you need more complicated input method support such as scim discussed next.

The input method support with scim

Setup of multilingual input for the Debian system is simplified by using the SCIM family of packages with the im-switch package. The list of SCIM packages are:

List of input method supports with scim.

1

2

package

popcon

locale

scim-anthy

9

Japanese

scim-canna

5

, ,

scim-skk

2

, ,

scim-prime

0

, ,

scim-tables-ja

*133

, , (not useful)

scim-tables-zh

*388

Chinese (for zh_*)

scim-pinyin

*333

, , (for zh_CN)

scim-chewing

*177

, , (for zh_TW)

scim-hangul

*54

Korean

scim-tables-ko

*43

, ,

scim-thai

*23

Thai

scim-m17n

*95

Multilingual: Indic, Arabic and others

scim-tables-additional

*92

, ,

scim-uim

*65

, ,

The kinput2 method and other locale dependent Asian classic input methods still exist but are not recommended for the modern UTF-8 X environment. The uim tool chain is an alternative approach for the international input method for the modern UTF-8 X environment which is also capable for non-X environment.

An example for Japanese

I find the Japanese input method started under English environment (en_US.UTF-8) very useful. Here is how I did it with SCIM.

  • Install the Japanese input tool package scim-anthy with its recommended packages such as im-switch.

  • Execute "im-switch -c" from user's shell and select "scim".

  • Relogin to user's account.
  • Verify setting by "im-switch -l".

  • Setup input method and mode by right clicking GUI toolbar. (You can reduce menu choice of input method)
  • Start SCIM input method by CTRL-SPACE

(!) In order to start SCIM under the non-CJK and non-en_US locale, you need to add list of those locales in UTF-8 to the ~/.scim/global or /etc/scim/global file as:

/SupportedUnicodeLocales = en_US.UTF-8,en_GB.UTF_8,fr_FR.UTF-8

Please note:

  • The im-switch command behaves differently if command is executed from root or not.

  • Input method started by im-switch depends on the locale.

  • Use of new immodule mechanism (via GTK_IM_MODULE) may cause instability during the library transition in unstable.

For the detail of setup, see /usr/share/doc/im-switch/README.Debian.gz, /usr/share/doc/scim/README.Debian.gz or /usr/share/doc/uim/README.Debian.gz. Here key points are described.

Disabling the input method

If you wish to input without going through XIM, set XMODIFIERS value to "none" while starting a program. This may be the case if you use Japanese input infrastructure egg on emacs. From shell, execute as:

$ XMODIFIERS=none emacs

In order to adjust the command executed by the Debian menu, place customized configuration in /etc/menu following method described in /usr/share/doc/menu/html .

The display output

Linux console can only display limited characters. (You need to use special terminal program such as jfbterm to display non-European languages on the non-X console.)

X Window can display any characters in the UTF-8 as long as required font data exists. (The encoding of the original font data is taken care by the X Window system and transparent to the user.)

The locale

The following will focus on the locale for applications run under X Window environment started from the gdm.

Rationale for UTF-8 locale

The [http://en.wikipedia.org/wiki/UTF-8 UTF-8] encoding is the modern and sensible text encoding system for I18N and enables to represent [http://en.wikipedia.org/wiki/Unicode Unicode] characters, i.e., practically all characters known to human. UTF stands for Unicode Transformation Format (UTF) schemes.

I recommend to use [http://en.wikipedia.org/wiki/UTF-8 UTF-8] locale for your desktop, e.g., "LANG=en_US.UTF-8". The first part of the locale detrmines messages presented by applications. For example, gedit(1) (text editor for the GNOME Desktop) under "LANG=fr_FR.UTF-8" locale can display and edit Chinese character text data while presenting menus in French, as long as required fonts and input methods are installed.

I also recommend to set the locale only using LANG environment variable. I do not see much benefit of setting a complicated combination of LC_* variables (see locale(1) manpage) under UTF-8 locale.

(!) The "LANG=en_US" is not "LANG=C" nor "LANG=en_US.UTF-8". It is "LANG=en_US.ISO-8859-1" (see: @{@basicsofencoding@}@).

Even plain English text may contain non-ASCII characters, e.g. left and right quotation marks are not available in ASCII:

“double quoted text”
‘single quoted text’

When [http://en.wikipedia.org/wiki/ASCII ASCII] plain text data is converted to [http://en.wikipedia.org/wiki/UTF-8 UTF-8] one, it has exactly the same content and size as the original ASCII one. So you loose nothing by deploying UTF-8 locale.

Some programs consume more memory after supporting I18N. This is because they are coded to use [http://en.wikipedia.org/wiki/UTF-32/UCS-4 UTF-32(UCS4)] internally to support Unicode for speed optimization and consume 4 bytes per each ASCII character data independent of locale selected. Again, you loose nothing by deploying UTF-8 locale.

<!> The sort order of characters with sort(1) is affected by the language choice of the locale. Spanish and English locale sort differently.

<!> The date format of ls(1) is affected by the locale. The date format of "LANG=C ls -l" and "LANG=en_US.UTF-8" are different.

The reconfiguration of the locale

In order for the system to access a particular locale, the locale data must be compiled from the locale database. (The Debian system does not come with all available locales pre-compiled unless you installed the locales-all package.) The full list of supported locales available for compiling are listed in /usr/share/i18n/SUPPORTED. This lists all the proper locale names. The following will list all the available UTF-8 locales already compiled to the binary form:

$ locale -a

The following command execution will reconfigure locale package:

  • to update the list of available locales,
  • to compile them into the binary form, and
  • to set the system wide default locale value in the /etc/defaults/locale for use by PAM (see: @{@pamandnss@}@).

# dpkg-reconfigure locales

The list of available locale should include "en_US.UTF-8" and all the interesting languages with "UTF-8".

The recommended default locale is "en_US.UTF-8" for US English. For other languages, please make sure to chose locale with "UTF-8". Any one of these settings can handle any international characters.

(!) Although setting locale to "C" will use US English message, it handles only ASCII characters.

Configuring system with LANG

The environment variable LANG (see: @{@langvariable@}@) is:

  • set initially by some display manager such as gdm for all X programs,

  • changed by the X session startup code via $HOME/.xsessionrc for all X programs (lenny feature),

  • set initially by the PAM mechanism of the login for the local Linux console programs,

  • set initially by the PAM mechanism of the ssh for the remote console programs, or

  • changed by the shell startup code, e.g. $HOME/.bashrc, for all console programs.

{i} It is good idea to install system wide default locale as "en_US.UTF-8" for maximum compatibility.

Specific locale only under X Window

You can chose specific locale only under X Window irrespective of your system wide default locale. This should provide your best desktop experience with stability.

This way, you can always access functioning character terminal with readable messages even when X Window system is not working. This becomes essential for languages which use non-roman characters such as Chinese, Japanese, and Korean.

For gdm, you can select different locale for the X session from its menu independent of the system default locale value in the /etc/defaults/locale. The locale for gdm program itself can be adjusted at the same time.

For simpler display manager, such as xdm, you can set the locale using PAM customization (see: @{@pamandnss@}@) as follows.

First, change the following line defining language environment variable in its PAM configuration file, such as /etc/pam.d/xdm:

auth    required        pam_env.so read_env=1 envfile=/etc/default/locale

into

auth    required        pam_env.so read_env=1 envfile=/etc/default/locale-x

Then create a /etc/defaults/locale-x file with "-rw-r--r-- 1 root root" permission containing, eg. for Japanese message:

LANG="ja_JP.UTF-8"

and keep the default /etc/defaults/locale file for other programs being:

LANG="en_US.UTF-8"

This is the most generic technique to customize locale.

Alernatively for this case, you may simply change locale using the $HOME/.xsessionrc file if you do not care about English message by the display manager.

Filename encoding

The mount(8) command may assume some file system (e.g. vfat) to be non-UTF-8 encoding while mounting them without mount option. The UTF-8 support in such case can be enabled by providing explicit mount option.

(!) When auto-mounting a hot-pluggable USB memory stick under modern desktop environment such as Gnome, you may provide such mount option by right clicking the icon on the desktop, click "Drive" tab, click to expand "Setting", and entering "utf8" to "Mount options:". The next time this memory stick is mounted, mount with UTF-8 is enabled.

(!) If you are upgrading system or moving disk drives from older non-UTF-8 system, file names with non-ASCII characters may be encoded in the historic and deprecated encodings such as "ISO-8859-1" or "eucJP". Please seek help of text conversion tools to convert them to "UTF-8". See: @{@textdataconversiontools@}@ .

Localizing messages and documentation

Translations exist for many of the text messages and documents that are displayed in the Debian system, such as error messages, standard program output, menus, and manual pages.

The aptitude list under "Tasks" -> "Localization" provide extensive list of useful packages for localizing messages and documentation.

For example, you can obtain the localized message for manpage by installing the manpages-<LANG>. To read the Italian-language manpage for <programname>, execute

LANG=it_IT.UTF-8 man <programname>

to read it from /usr/share/man/it/.