Japanese Environment
I hereby describe methods to set up Japanese environment under Debian etch for your reference. (This should give good reference to other non-European languages.)
Each command is not explained here in detail. Please refer to the manpages.
In order to setup and use not only Japanese environment but also multilingual environment smoothly, please select the locale with UTF-8 encoding.
Required packages for Japanese environment
Following lists required packages for Japanese environment.
- Imput method for Japanese
- Packages to introduce when scim system is deployed. (I use this)
- im-switch
- scim and its auto-installed packages as follows
- libscim8c2a etc.
- scim-anthy and its auto-installed packages as follows
- anthy
- libanthy0
- libscim8c2a etc.
- Packages to introduce when uim system is deployed. u
- im-switch
- uim and its auto-installed packages as follows
- uim-common
- uim-utils
- uim-gtk2.0
- uim-xim
- uim-fep (required only for console)
- uim-anthy and its auto-installed packages as follows
- anthy
- libanthy0
- linuim3
- uim-common
- uim-utils
- Packages to introduce when scim system is deployed. (I use this)
- Japanese fonts
- unifont
- ttf-kochi-gothic
- ttf-kochi-mincho
- ttf-vlgothic
- Japanese messages
- manpages-ja
- manpages-ja-dev
- openoffice.org-help-ja
- openoffice.org-l10n-ja
- iceweasel-l10n-ja
- (firefox-locale-ja is old and should be removed)
- kde-i18n-ja (required only when KDE is deployed)
- Japanese documentations
- doc-linux-ja-text
- doc-linux-ja-html
- Japanese related tools
- lv
- nkf
- jfbterm
== What is locale ==The best supported language region is U
The locale is used for LANG environment variable to define language environment. It has structureof xx_YY.ZZZZ and has following meanings:
xx
language
yy
region
zzzz
encoding
The language region of Japan is ja_JP but if it is used alone it is treated as tradional ja_JP.eucJP . The language region of US (the best supported) is en_US but if it is used alone it is treated as tradional en_US.ISO8859-1.
For example, the encoding system often used for Japanese are:
UTF-8
recent standard, multilingual compatibility
eucJP
old UNIX standard, only for Japanese
Shift-JP
old Microsoft standard, only for Japanese
ISO-2022-JP
standard for Japanese e-mail, use only 7 bit code, only for Japanese
ISO-8859-1
old standard for western European languages, ASCII+accented characters, 8 bit code
ASCII
US standard, 7 bit code
These encodings are well thought out to keep them compatible within ASCII code ranges.
If you happen not to created ja_JP.UTF-8 locale, please execute followings to enable Japanese UTF-8 environment.
$ sudo dpkg-reconfigure locales
Set up of language related environment variables
Each program behaves differently depending on the set up of language related environment variables.
Here, you have to pay attention to the fact that some program uses PAM (pluggable Authentification Module) and the environment variable set by PAM has priority.
Both /etc/environment and /etc/defaults/locale files define
LANG="ja_JP.UTF-8"
when Japanese is selected during the etch installation processunder etch (as of December 2006).
Under normal X environment, this is OK with me. But I do not like to use Japanese for console session after system crash or for su session. For such session, I like most robust environment for console thus I set LANG definition for them as:
LANG="en_US.UTF-8"
There may be a way to work around this problem using kon2 or frame buffer console. This is purely my taste issue.
But this will make gdm to be in English. (X session itself can be set to Japanese from gdm menu.)
I use PAM to start gdm with Japanese menu as follows. First Let's change the following line defining language environment variable in /etc/pam.d/gdm or /etc/pam.d/gdm-autologin (the actual file depends on display manager and its setup):
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-gdm
.Then create a file /etc/defaults/locale-gdm containing:
LANG="ja_JP.UTF-8"
.Then GDM becomes Japanese. Actual language (value for LANG) can be set through GDM menu. So you can still use English environment in X.
Setup of Japanese input in Debian
Setup of Japanese input in Debian is simplified by using im-switch.
For complicated setups specific to the each Japanese input method is best handled by the accompanying GUI configuration tool for each input method. For these configuration tools can be activated by clicking icon for the setup in the toolbar of Japanese input methods or clicking configuration tool icon on Gnome toolbar as [Desktop] -> [Configuration].
First you install im-switch and one of the Japanese input tool chain packages, uim or scim.
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.
im-switch command behaves differently if command is executed from root or not.
- SCIM system (I use this)
Install packages with scim as its part of name and looking interesting to you. (Search them using "l" in aptitude) scim, scim-anthy (Japanese), ... etc.
Execute "im-switch -c" from user's shell and select "scim".
- Relogin to user's account.
- Set input method and mode by clicking GUI toolbar. (You can reduce menu choice of input method)
- Start input method by CTRL-SPACE
- SCIM system with using X session
Install packages with scim as its part of name and looking interesting to you. (Search them using "l" in aptitude) scim, scim-anthy (Japanese), ... etc.
Execute "im-switch -c" from user's shell and select "scim".
- You manually change im-switch configuration set up not to start scim. (Ugly but this is the current limitation of im-switch infrastructure.)
$ cd ~/.xinput.d $ ls -l lrwxrwxrwx 1 osamu osamu 28 2006-11-25 00:50 ja_JP -> /etc/X11/xinit/xinput.d/scim $ cat ja_JP | sed 's/XIM_PROGRAM=.*/XIM_PROGRAM=/;s/XIM_ARGS=.*/XIM_ARGS=/'>ja.JP.file $ mv ja.JP.file ja.JP
Register "scim -d in session manager started by Desktop->Preferences->Session .
- Relogin to user's account and refresh X session.
- Set input method and mode by clicking GUI toolbar. (You can reduce menu choice of input method)
- Start input method by CTRL-SPACE
- UIM system (following the explanation in im-switch README.Debian using gnome-session)
Install packages with uim as its part of name and looking interesting to you. (Search them using "l" in aptitude) uim, uim-anthy (Japanese), uim-gtk2.0, uim-xim, ... etc.
Execute "im-switch -c" from user's shell and select "uim".
もし、ツールバーに状況表示したい際には、Desktop->Preferences->Session でセッションマネージャーに"}" を起動するように登録。
- もし、シストレイに状況表示したい際には、"uim-toolbar-gtk-systray"を代わりに選ぶ。
- もし、KDEが好きな際には、"uim-toolbar-qt"を代わりに選ぶ。
- ユーザーアカウントにリログインしてXセションを更新する。
- 入力方法やモードはGUIのツールバーを叩いて設定する。
- UIMの変換起動はCNTL-SPACE
- UIMでの変換モード切替えon/offはSHIFT-SPACE(通常は、直接入力のon/offになる)
上記のUIMの設定の変化形として、セッションマネージャーに起動を登録する代わりに、shellから"uim-toolbar-gtk >/dev/null 2>dev/null &"としてツールバーを起動し、シャットダウン時に自動登録され再起動時に立ち上がるのにたよるのも方法してあります。(uim-ximが安定してからの遅延起動がうまくいくかどうかはまだテストせず。)
- UIM系での設定を選んだ場合(セッションマネージャーを使わない環境。uimのパッケージ中にある説明と同じ。)
uim と名の付く役に立ちそうなパッケージをインストールする。("l"をaptitudeで使って見付ける)uim, uim-anthy (Japanese), uim-gtk2.0, uim-xim, ...等。
普通はユーザーとして"im-switch -c" を実行し"uim-toolbar"を選ぶ。
もし、シストレイに状況表示したい際には、ユーザーとして"im-switch -c" を実行し"uim-systray"を代わりに選ぶ。
もし、KDEが好きな際には、ユーザーとして"im-switch -c" を実行し"uim-toolbar-qt"を代わりに選ぶ。
もし、なにも状態表示が入らないという際には、ユーザーとして"im-switch -c" を実行し"uim"を代わりに選ぶ。
- ユーザーアカウントにリログインしてXセションを更新する。
- 入力方法やモードはGUIのツールバーを叩いて設定する。
- UIMの変換起動はCNTL-SPACE
- UIMでの変換モード切替えon/offはSHIFT-SPACE(通常は、直接入力のon/offになる)
上記ではセッションマネージャーに頼らずツールバーが起動されます。再ログインするときなどにセッションマネージャーにもよってツールバーが起動され複数起動になる場合などは、Desktop->Preferences->Session でセッションマネージャーが"uim-toolbar-gtk" を(再)起動しないように登録するとよいです。
uim-fepパッケージを用いるとコンソールでの日本語入力ができます。(日本語表示のためのjfbtermは私は良く分かりません)そういった意味でUIMは魅力があります。
MODIFIERSを設定せずen_US同様の挙動を得る。
"im-switch -c" を実行し"none"を選ぶ。
- ユーザーアカウントにリログインしてXセションを更新する。
- デフォルト挙動を回復する
"im-switch -a" を実行する。
- ユーザーアカウントにリログインしてXセションを更新する。
- 設定状況の確認方法
"im-switch -l" を実行する。
im-switchによってスタートされる入力方法はlocaleの値に依存することは注意してください。
英語環境下ででも、im-switchによって日本語等の入力できる環境をスタートできます。en_US.UTF-8環境で日本語での入力は意外と便利です。
SCIMがCJK以外のlocaleで起動するようにするには~/.scim/globalが/etc/scim/globalにあなたがSCIMを起動したいlocaleを
/SupportedUnicodeLocales = en_US.UTF-8,en_GB.UTF_8,fr_FR.UTF-8
等と列記します。
GTK_IM_MODULE変数に新規のimmoduleメカニズムを設定して使わないとと考えるかもしれませんが、現状はGTK_IM_MODULE変数にximに設定するのが最も安定するようです。詳しくは/usr/share/doc/scim/README.Debian.gzに英語で書いてあります。
各プログラムとの連携
emacsの状況
- emacsは賢いのでいろんなエンコード体系に対応しています。それだけにその設定には気を付けてください。
- emacsはXやFEPなどの外部ソフトに頼らない独自の日本語入力インフラが色々あるようです。(eggなど。)
もしXIMを経由せずに日本語入力したい際には、emacsを立ち上げる際のXMODIFIERSの値を"none"としてやればいいということです。シェルからだと:
$ XMODIFIERS=none emacs
です。このようにDebianのmenuを触るのは、/usr/share/doc/menu/htmlの手順にしたがって/etc/menuにカスタマイズした定義を置いてください。
vimの状況
- vimも賢いのでいろんなエンコード体系に対応しています。基本はUTF-8で使うように設定には気を付けてください。特別な入力関係の設定は現在要りません。詳しくは、UTF-8 vim[:UTF8vimE: (English)][:UTF8vim: (日本語)]を参照ください。