Differences between revisions 1 and 19 (spanning 18 versions)
Revision 1 as of 2006-12-31 06:29:40
Size: 14940
Editor: OsamuAoki
Comment:
Revision 19 as of 2011-12-12 14:09:12
Size: 5410
Editor: OsamuAoki
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[JapaneseEnvironment|(Japanese)]] [[OsamuAoki|Wiki links]]
Line 2: Line 4:
I hereby describe methods to set up Japanese environment under Debian etch for your reference. I hereby describe methods to set up a Japanese environment under Debian etch for your reference.  (This should give good reference to other non-European languages.)
Line 6: Line 8:
<!> In order to setup and use not only Japanese environment but also multilingual environment smoothly, please select the locale with UTF-8 encoding. <!> In order to set up and use not only Japanese environment but also multilingual environment smoothly, please select the locale with UTF-8 encoding.
Line 8: Line 10:
== 日本語環境に必要なパッケージ == == Required packages for Japanese environment ==
Following lists required packages for Japanese environment. (For other languages, refer to the language task contents.)
Line 10: Line 13:
以下に日本語環境整備に必要とされるパーケージをリストします。  * Input method for Japanese
  * Packages to introduce when scim system is deployed. (I use this)
   * im-config
   * ibus and its family of packages: auto-installed packages for ibus-mozc is good choice
   * relogin to X
   * set up ibus via its GUI configuratiourto use mozc
 * Japanese fonts
  * fonts-ipafont
  * fonts-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
Line 12: Line 38:
 * 日本語入力
   * scim系を選んだ場合に導入するパッケージ(私はこれを使ってます)
     * im-switch
     * scimと自動的に導入される以下のパッケージ
       * libscim8c2a他
     * scim-anthyと自動的に導入される以下のパッケージ
       * anthy
       * libanthy0
       * libscim8c2a他
   * uim系を選んだ場合に導入するパッケージ
     * im-switch
     * uimと自動的に導入される以下のパッケージ
       * uim-common
       * uim-utils
       * uim-gtk2.0
       * uim-xim
       * uim-fep(コンソールで使う際のみ必要)
     * uim-anthyと自動的に導入される以下のパッケージ
       * anthy
       * libanthy0
       * linuim3
       * uim-common
       * uim-utils
 * 日本語フォント
   * unifont
   * ttf-kochi-gothic
   * ttf-kochi-mincho
   * ttf-vlgothic
 * 日本語メッセージ
   * 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 (KDEを導入した際のみ必要)
 * 日本語でのドキュメンテーション
   * doc-linux-ja-text
   * doc-linux-ja-html
 * 日本語関連ツール
   * lv
   * nkf
   * jfbterm
<!>  Read {{{/usr/share/doc/ibus/README.Debian.gz}}} in detail for input method.
Line 56: Line 40:
== localeとは == <!>  Read FontsProprietaryJapaneseFonts for more font hints
Line 58: Line 42:
LANG環境変数にあたえ言語環境を定義する、localeですが{{{xx_YY.ZZZZ}}}と言う構造なっていて以下の意味があります。
 || xx || 言語||
 || yy || 地域 ||
 || zzzz || エンコーディング ||
== What is locale ==
The locale is used for LANG environment variable to define language environment. It has a structure of {{{xx_YY.ZZZZ}}} and has following meanings:
Line 63: Line 45:
日本の言語地域はja_JPで、これだけだとデフォールトの昔の ja_JP.eucJPの意味になります。
米国(ある意味で一番標準でサポートが良い)の言語地域はen_USで、これだけだとデフォールトの昔の en_US.ISO8859-1の意味になります。
|| xx || [[http://en.wikipedia.org/wiki/ISO_639|language codes ]] ||
|| yy || [[http://en.wikipedia.org/wiki/ISO_3166-3|country codes ]]  ||
|| zzzz || encoding ||
Line 66: Line 49:
ちなみに日本に御縁のあるエンコードシステムですが:
 || UTF-8 || 最近の主流、多国語対応 ||
 || eucJP || 昔のUNIXの標準、日本語のみ対応 ||
 || Shift-JP || 昔のMicrosoftの標準、日本語のみ対応 ||
 || ISO-2022-JP || 日本語e-mailの主流、7-bitコードのみ、日本語のみ対応 ||
 || ISO-8859-1 || 昔の西欧の主流、Ascii+西欧の文字対応、8ビット ||
 || ASCII || 米国の主流、7ビット ||
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.
Line 74: Line 51:
これらはうまく工夫されていて、ASCIIのコード範囲に収まる文字だったら上記どのエンコーディング体系でも同じです。 For example, the encoding system often used for Japanese are:
Line 76: Line 53:
もしja_JP.UTF-8のlocaleをなんらかの理由でまだ作成設定してないなら || UTF-8 || [[http://en.wikipedia.org/wiki/UTF-8|recent standard, multilingual compatibility]] ||
|| eucJP || [[http://en.wikipedia.org/wiki/EUC-JP|old UNIX standard, only for Japanese]] ||
|| Shift-JIS || [[http://en.wikipedia.org/wiki/Shift-jis|old Microsoft standard, only for Japanese]] ||
|| ISO-2022-JP || [[http://en.wikipedia.org/wiki/ISO_2022|standard for Japanese e-mail, use only 7 bit code, only for Japanese]] ||
|| ISO-8859-1 || [[http://en.wikipedia.org/wiki/ISO_8859|old standard for western European languages, ASCII+accented characters, 8 bit code]] ||
|| ASCII || [[http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange|US standard, 7 bit code]] Simply set LANG=C ||
These encodings are well thought out to keep them compatible within ASCII code ranges.

If you accidentally haven't created the ja_JP.UTF-8 locale, please execute the following to enable Japanese UTF-8 environment.
Line 80: Line 66:
をして作成してください。これが無ければUTF-8の日本語環境は無理です。 == Set up of language related environment variables ==
Each program behaves differently depending on the set up of language related environment variables.
Line 82: Line 69:
== 言語関連の環境変数の設定 == 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.
Line 84: Line 71:
各種プログラムの挙動は言語関連の環境変数(LANGやLC_ALL等)への設定によって変わります。 Both {{{/etc/environment}}} and {{{/etc/defaults/locale}}} files define
Line 86: Line 73:
ここで注意が必要なのは、一部のプログラムはPAM(Pluggable Authentication Modules)を使っているので、PAMでの環境変数設定が優先するということです。

etchの標準日本語インストール(2006年11月現在のRC1の前のバージョンの情報)では、日本語でのインストールを選ぶと{{{/etc/environment}}}と{{{/etc/defaults/locale}}}というファイルともに
Line 92: Line 76:
という内容を定義していると思います。 when Japanese is selected during the etch installation process under etch (as of December 2006).
Line 94: Line 78:
通常X環境だと気にならないのですがクラシュしたりしてコンソールを使う際や{{{su}}}を使うときにも日本語なので私は嫌いです。そういうときは文字化けのない一番確実な環境がいいので、私は日本語表示しない設定にコンソールではすべくこれらのファイルのLANG定義内容を:
{{{
LANG="en_US.UTF-8"
}}}
としています。(フレームバッファーコンソールやkon2を{{{uim-fep}}}や{{{emacs}}}とでUTF-8環境下でうまく動かす方はこれは必要ないかもしれません。基本的に私の趣味の問題です。こうしなくても日本語環境はできます。)
Line 100: Line 79:
ただこのままだとディスプレーマネージャーの{{{gdm}}}が英語です。X自体はこれでもLanguageでJapaneseを選べばちゃんと日本語でのメニュー等の表示に対応できます。

でも折角ですから私はディスプレーマネージャーの{{{gdm}}}を日本語メニューで立ち上げています。これにはPAMを使って対応します。
まず、{{{/etc/pam.d/gdm}}}や{{{/etc/pam.d/gdm-autologin}}}(このファイルはお使いになっているディスプレーマネージャー次第ですが…)の中の
{{{
auth required pam_env.so read_env=1 envfile=/etc/default/locale
}}}
のlocale関連の環境変数を定義する行を
{{{
auth required pam_env.so read_env=1 envfile=/etc/default/locale-gdm
}}}
と直します。そして{{{/etc/defaults/locale-gdm}}}というファイルを作り、
{{{
LANG="ja_JP.UTF-8"
}}}
という内容にします。これでGDMは日本語になります。Xの中で使われる言語(LANGの値)はGDMのメニューから選べます。だからこうしておいてもXでは英語の環境も選べます。

== Debianでの日本語入力設定 ==

Debianでの日本語入力設定は{{{im-switch}}}を用いるのが簡単です。

そしてさらに複雑な各日本語入力ツールチェイン固有の設定は、各日本語入力ツールチェイン付随するGUIコンフィギュレーションツールを用いて設定していきましょう。このコンフィギュレーションツールは各日本語入力のツールバーの設定アイコンをたたくか、Gnomeのツールバーのメニューで「デスクトップ」->「設定」で表示されるメニューから該当する設定ツールアイコンをたたいて設定を行います。

まず、{{{im-switch}}}パッケージと{{{uim}}}か{{{scim}}}のどちらかの日本語入力ツールチェインパッケージをインストールします。

詳しい設定のことは、{{{/usr/share/doc/im-switch/README.Debian.gz}}}や{{{/usr/share/doc/scim/README.Debian.gz}}}や{{{/usr/share/doc/uim/README.Debian.gz}}}に英語で書いてあります。以下に要点だけを日本語にします。

<!> {{{im-switch}}}コマンドは、コマンドがrootから実行されたかどうかで挙動が違います。

  * SCIM系での設定を選んだ場合(セッションを使わない方法。私はこれを使ってます。)
    * scim と名の付く役に立ちそうなパッケージをインストールする。("l"を{{{aptitude}}}で使って見付ける) {{{scim, scim-anthy (Japanese), ...}}}等。
    * ユーザーとして"{{{im-switch -c}}}" を実行し"scim"を選ぶ。
    * ユーザーアカウントにリログインしてXセションを更新する。
    * 入力方法やモードはGUIのツールバーを叩いて設定する。(忙しすぎる変換ツール候補表示を減らすこともできます。)
    * 起動はCTRL-SPACE

  * SCIM系での設定を選んだ場合(セッションを使う方法。)
    * scim と名の付く役に立ちそうなパッケージをインストールする。("l"を{{{aptitude}}}で使って見付ける) {{{scim, scim-anthy (Japanese), ...}}}等。
    * ユーザーとして"{{{im-switch -c}}}" を実行し"scim"を選ぶ。
    * マニュアルでim-switchの環境設定ファイルからはscimプログラム自身は起動しないようにする。(こんなことするより上行で"scim-nostart"を選べば良いようにいずれしないといけませんね。)
{{{
$ 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
}}}
    * Desktop->Preferences->Session でセッションマネージャーに"{{{scim -d}}}" を起動するように登録。
    * ユーザーアカウントにリログインしてXセションを更新する。
    * 入力方法やモードはGUIのツールバーを叩いて設定する。(忙しすぎる変換ツール候補表示を減らすこともできます。)
    * 起動はCTRL-SPACE

  * UIM系での設定を選んだ場合(gnome-sesseionを使うim-switchパッケージ中の説明)
    * uim と名の付く役に立ちそうなパッケージをインストールする。("l"を{{{aptitude}}}で使って見付ける){{{uim, uim-anthy (Japanese), uim-gtk2.0, uim-xim, ...}}}等。
    * ユーザーとして"{{{im-switch -c}}}" を実行し"uim"を選ぶ。
      * もし、ツールバーに状況表示したい際には、Desktop->Preferences->Session でセッションマネージャーに"{{uim-toolbar-gtk}}}" を起動するように登録。
      * もし、シストレイに状況表示したい際には、"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"としてやればいいということです。シェルからだと:
== Working with key programs ==
=== emacs situation ===
 * emacs is quite smart and copes well with many encoding systems. So please pay extra attention to it.
 * emacs has its own unique Japanese input infrastructure (egg etc.) which does not rely on external programs such as X nor FEP.
 * If you wish to input without going through XIM, set {{{XMODIFIERS}}} value to "none" while starting emacs. From shell, execute as:
Line 212: Line 87:
です。このようにDebianのmenuを触るのは、{{{/usr/share/doc/menu/html}}}の手順にしたがって{{{/etc/menu}}}にカスタマイズした定義を置いてください。 In order to adjust Debian menu, place customized configuration in {{{/etc/menu}}} following the method described in {{{/usr/share/doc/menu/html}}}.
Line 214: Line 89:
=== vimの状況 ===
  vimも賢いのでいろんなエンコード体系に対応しています。基本はUTF-8で使うように設定には気を付けてください。特別な入力関係の設定は現在要りません。詳しくは、UTF-8 vim[:UTF8vimE: (English)][:UTF8vim: (日本語)]を参照ください。
=== vim situation ===
 . vim is also quite smart and copes well with many encoding syatems. So please pay extra attention to it and basically try to use vim under UTF-8. No special input method configuration needed. Please refer to "Method to edit non-UTF-8 encoded text files under UTF-8 vim" [[UTF8vimE|(English)]] [[UTF8vim|(Japanese)]]

== IBus ==
Recently [[http://code.google.com/p/ibus/|IBus]] has become the most widely used input framework - it's probably the best choice for Japanese input in Debian

There are two Japanese IBus engines: {{{ibus-anthy}}} and {{{ibus-mozc}}}. {{{ibus-mozc}}} is a client of another input project, sponsored by Google? {{{ibus-anthy}}} is more mature? The Ubuntu {{{language-support-input-ja}}} package depends on {{{ibus-anthy}}} - {{{ibus-anthy}}} is probably what you want,

For wheezy, please make sure to use {{{im-config}}}.

{{{
$ sudo aptitude -DR install ibus-anthy
}}}

The Ubuntu {{{language-support-fonts-ja}}} package depends on {{{ttf-takao-gothic}}} and {{{ttf-takao-mincho}}},

{{{
$ sudo aptitude -DR install ttf-takao
}}}

(Japanese) Wiki links

Japanese Environment

I hereby describe methods to set up a 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 set up 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. (For other languages, refer to the language task contents.)

  • Input method for Japanese
    • Packages to introduce when scim system is deployed. (I use this)
      • im-config
      • ibus and its family of packages: auto-installed packages for ibus-mozc is good choice
      • relogin to X
      • set up ibus via its GUI configuratiourto use mozc
  • Japanese fonts
    • fonts-ipafont
    • fonts-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

<!>  Read /usr/share/doc/ibus/README.Debian.gz in detail for input method.

<!>  Read ?FontsProprietaryJapaneseFonts for more font hints

What is locale

The locale is used for LANG environment variable to define language environment. It has a structure of xx_YY.ZZZZ and has following meanings:

xx

language codes

yy

country codes 

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-JIS

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 Simply set LANG=C

These encodings are well thought out to keep them compatible within ASCII code ranges.

If you accidentally haven't created the ja_JP.UTF-8 locale, please execute the following to enable Japanese UTF-8 environment.

$ sudo dpkg-reconfigure locales

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 process under etch (as of December 2006).

Working with key programs

emacs situation

  • emacs is quite smart and copes well with many encoding systems. So please pay extra attention to it.
  • emacs has its own unique Japanese input infrastructure (egg etc.) which does not rely on external programs such as X nor FEP.
  • If you wish to input without going through XIM, set XMODIFIERS value to "none" while starting emacs. From shell, execute as:

$ XMODIFIERS=none emacs

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

vim situation

  • vim is also quite smart and copes well with many encoding syatems. So please pay extra attention to it and basically try to use vim under UTF-8. No special input method configuration needed. Please refer to "Method to edit non-UTF-8 encoded text files under UTF-8 vim" (English) (Japanese)

IBus

Recently IBus has become the most widely used input framework - it's probably the best choice for Japanese input in Debian

There are two Japanese IBus engines: ibus-anthy and ibus-mozc. ibus-mozc is a client of another input project, sponsored by Google? ibus-anthy is more mature? The Ubuntu language-support-input-ja package depends on ibus-anthy - ibus-anthy is probably what you want,

For wheezy, please make sure to use im-config.

$ sudo aptitude -DR install ibus-anthy

The Ubuntu language-support-fonts-ja package depends on ttf-takao-gothic and ttf-takao-mincho,

$ sudo aptitude -DR install ttf-takao