Difference between revisions of "Input Japanese using uim"

From ArchWiki
Jump to: navigation, search
(Tips: Add mozc_tool commands)
(Troubleshooting)
(31 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
[[Category:Internationalization]]
 
[[Category:Internationalization]]
 
[[ja:Input Japanese using uim]]
 
[[ja:Input Japanese using uim]]
This page explains how to get the Japanese input to work using [http://code.google.com/p/uim/ uim].<br/>
+
This page explains how to get the Japanese input to work using [http://code.google.com/p/uim/ uim].
If you use SCIM, see [[Smart Common Input Method platform]].<br/>
+
 
 +
If you use SCIM, see [[Smart Common Input Method platform]].
 +
 
 
If you use IBus, see [[Ibus]].
 
If you use IBus, see [[Ibus]].
  
 
== Installation ==
 
== Installation ==
 +
 
You need the following packages to input Japanese.
 
You need the following packages to input Japanese.
  
 
* Japanese fonts
 
* Japanese fonts
* Japanese input method (Kana to Kanji conversion engine): This article describes about [http://en.sourceforge.jp/projects/anthy/ Anthy] and [http://code.google.com/p/mozc/ Mozc].
+
* Japanese input method (Kana to Kanji conversion engine)
 
* Input method framework: uim
 
* Input method framework: uim
  
 
=== Japanese fonts ===
 
=== Japanese fonts ===
 +
 
''see also [[Fonts]] and [[Font Configuration]] for configuration or more detail.''
 
''see also [[Fonts]] and [[Font Configuration]] for configuration or more detail.''
  
 
Recommended Japanese fonts are as follows.
 
Recommended Japanese fonts are as follows.
* [http://ossipedia.ipa.go.jp/ipafont/ IPA fonts] ([[Arch User Repository|AUR]]: {{AUR|otf-ipafont}})
+
* [http://ossipedia.ipa.go.jp/ipafont/ IPA fonts] || {{Pkg|otf-ipafont}}
:A high quality and formal style opensource font set including Gothic (sans-serif) and Mincho (serif) glyphs. Default font of openSUSE-ja.
+
: A high quality and formal style opensource font set including Gothic (sans-serif) and Mincho (serif) glyphs. Default font of openSUSE-ja.
* [http://dicey.org/vlgothic/ VL Gothic] (AUR: {{AUR|ttf-vlgothic}})
+
* [http://dicey.org/vlgothic/ VL Gothic] ([[Arch User Repository|AUR]]: {{AUR|ttf-vlgothic}})
:Default Gothic font of Debian-ja, Fedora-ja, Vine Linux, et al.
+
: Default Gothic font of Debian-ja, Fedora-ja, Vine Linux, et al.
 
* [http://www.geocities.jp/ep3797/modified_fonts_01.html UmePlus Gothic] (AUR: {{AUR|ttf-umeplus}})
 
* [http://www.geocities.jp/ep3797/modified_fonts_01.html UmePlus Gothic] (AUR: {{AUR|ttf-umeplus}})
:Default Gothic font of Mandriva Linux ja environment.
+
: Default Gothic font of Mandriva Linux ja environment.
  
 
If you want to show [http://en.wikipedia.org/wiki/2channel_Shift_JIS_art 2channel Shift JIS art] properly, use one of the following fonts:
 
If you want to show [http://en.wikipedia.org/wiki/2channel_Shift_JIS_art 2channel Shift JIS art] properly, use one of the following fonts:
Line 28: Line 32:
  
 
=== uim ===
 
=== uim ===
 +
 
==== Using pacman ====
 
==== Using pacman ====
Pull down the necessary things with a :
+
 
# pacman -S uim
+
[[pacman|Install]] {{Pkg|uim}} from the [[official repositories]].
  
 
==== Compiling uim from source using PKGBUILD ====
 
==== Compiling uim from source using PKGBUILD ====
For instance, if you want to build uim with your configurationin, you can compile from source.
 
  
===== Arch's configuration=====
+
If you want to build uim with your configurationin, you can compile from source, using [[ABS]] for istance. See [http://code.google.com/p/uim/wiki/InstallUim official wiki] for all configure options.
In Arch official repository, uim is built with the following custom configuration (as of 1.7.1):
+
* {{Ic|--with-anthy-utf8}} : Enable Anthy(UTF-8) support
+
* {{Ic|--with-qt4}} : Build uim-tools for Qt
+
  
Please see [http://code.google.com/p/uim/wiki/InstallUim official wiki] for all configure options.
+
In Arch official repositories, uim is built with the following custom configuration (as of 1.8.6):
 +
* {{ic|--with-anthy-utf8}} - Enable Anthy(UTF-8) support
 +
* {{ic|--with-qt4-immodule}} - Build Qt4 immodule
 +
* {{ic|--with-qt4}} - Build uim-tools for Qt4
  
===== Steps to build=====
+
If you want KDE4 plasma widget, install {{Pkg|automoc4}} for making dependency, and add {{ic|--enable-kde4-applet}} option to PKGBUILD file.
The one of the easy way to build from source is using ABS.<br />
+
First, install ABS:
+
# pacman -S abs
+
Update ABS:
+
# abs
+
 
+
Then, copy uim's directory to under your $HOME. For example:
+
$ cp -R /var/abs/extra/uim ~/sources/
+
 
+
Edit PKGBUILD.
+
 
+
Finally, run makepkg under uim directory to make and install package:
+
$ makepkg -s -i
+
  
 
=== Input method ===
 
=== Input method ===
 +
 
==== Anthy ====
 
==== Anthy ====
 +
 
Anthy is one of the most popular Japanese input methods in the open source world. However, it has not been maintained for a long time. [http://wiki.debian.org/Teams/DebianAnthy Debian succeeds it] from May 2010.
 
Anthy is one of the most popular Japanese input methods in the open source world. However, it has not been maintained for a long time. [http://wiki.debian.org/Teams/DebianAnthy Debian succeeds it] from May 2010.
  
To install Anthy :
+
Install {{Pkg|anthy}} from the official repositories.
# pacman -S anthy
+
  
 
===== Extra dictionary =====
 
===== Extra dictionary =====
 +
 
Anthy's default dictionary does not include several characters which are not specified on EUC-JP (JIS X 0208) such as "①", "♥", etc. [http://en.sourceforge.jp/projects/alt-cannadic/ alt-cannadic] provides extra dictionaries including those characters.
 
Anthy's default dictionary does not include several characters which are not specified on EUC-JP (JIS X 0208) such as "①", "♥", etc. [http://en.sourceforge.jp/projects/alt-cannadic/ alt-cannadic] provides extra dictionaries including those characters.
  
Line 77: Line 70:
  
 
==== Modified Anthy (anthy-ut) ====
 
==== Modified Anthy (anthy-ut) ====
 +
 
[http://www.geocities.jp/ep3797/anthy_dict_01.html Modified Anthy] is a set of patches and huge extended dictionaries which aims to improve the Kana to Kanji conversion quality of original Anthy.
 
[http://www.geocities.jp/ep3797/anthy_dict_01.html Modified Anthy] is a set of patches and huge extended dictionaries which aims to improve the Kana to Kanji conversion quality of original Anthy.
  
Line 83: Line 77:
 
* Huge extended dictionalies by [http://www.geocities.jp/ep3797/anthy_dict_01.html UTSUMI]
 
* Huge extended dictionalies by [http://www.geocities.jp/ep3797/anthy_dict_01.html UTSUMI]
  
{{Warning|Modified Anthy applies to only Anthy (UTF-8). So you have to choose '''Anthy (UTF-8)''' for default input method on uim.}}
+
{{Warning|
{{Warning|Modified Anthy does not have compatibility of the dictionaries and learning data with original Anthy.}}
+
* Modified Anthy applies to only Anthy (UTF-8). So you have to choose '''Anthy (UTF-8)''' for default input method on uim.
 +
* Modified Anthy does not have compatibility of the dictionaries and learning data with original Anthy.
 +
}}
 +
 
 +
===== Compiling modified Anthy using PKGBUILD =====
  
===== Compiling Modified Anthy using PKGBUILD =====
 
 
Modified Anthy is available on AUR named {{AUR|anthy-ut}}.
 
Modified Anthy is available on AUR named {{AUR|anthy-ut}}.
  
Line 108: Line 105:
  
 
==== Mozc ====
 
==== Mozc ====
[http://code.google.com/p/mozc/ Mozc] (on [https://aur.archlinux.org/packages.php?K=mozc AUR]) is a Japanese open source input method that originates from [http://www.google.com/intl/ja/ime/ Google Japanese Input]. It is considered to have better conversion quality than Anthy as for multi segments conversion (e.g. one sentence) in a lump but the dictionary is not as complete as Google Japanese Input. Though Mozc adapts to only ibus input method framework, [http://code.google.com/p/macuim/ macuim] provides uim-mozc plugin and you can use it with {{AUR|mozc-svn}} or {{AUR|mozc-ut}} on AUR.
 
  
* {{AUR|mozc-svn}}
+
''See [[Mozc]].''
** mozc-svn builds with the published svn repository instead of source tarball and can build uim-mozc plugin. {{Note|If you do not use uim (use ibus), you should not use mozc-svn. It is exactly similar to mozc (published svn repository is not actually trunk) and run-time of makepkg of mozc-svn will be longer than mozc.}}
+
* {{AUR|mozc-ut}}
+
** mozc-ut comes with [http://www.geocities.jp/ep3797/mozc_01.html Mozc UT dictionary] and can build uim-mozc plugin. The dictionary adds over 350,000 words into original.{{Note|Building mozc-ut requires further long time to generate dictionary seed.}}
+
  
Each packages consist as follows:
+
[http://code.google.com/p/mozc/ Mozc] is a Japanese Input Method Editor (IME) designed for multi-platform such as Chromium OS, Windows, Mac and Linux which originates from [http://www.google.com/intl/ja/ime/ Google Japanese Input].
{| class="wikitable" style="text-align:center;margin:0 2em auto"
+
!Package !! mozc !! mozc-svn !! mozc-ut !! description
+
|-
+
!Group
+
| mozc-im || mozc-im-svn || mozc-im-ut ||
+
|-
+
!rowspan="5" | Component
+
| mozc || mozc-svn || mozc-ut || Server part of the Mozc
+
|-
+
| ibus-mozc || ibus-mozc-svn || ibus-mozc-ut || IBus engine module (optional)
+
|-
+
| <small>''N/A''</small> || uim-mozc-svn || uim-mozc-ut || uim plugin module (optional)
+
|-
+
| <small>''N/A''</small> || fcitx-mozc-svn || <small>''N/A''</small> || Fcitx module (optional)
+
|-
+
| emacs-mozc || emacs-mozc-svn || emacs-mozc-ut || Mozc for Emacs (optional)
+
|}
+
  
===== Using Unofficial user repository =====
+
Though {{AUR|Mozc}} adapts to only ibus input method framework, [http://code.google.com/p/macuim/ macuim] provides uim-mozc plugin.
There is an unofficial user repository of Mozc. Add the following into /etc/pacman.conf.
+
 
 +
===== Mozc (Vanilla) =====
 +
 
 +
{{AUR|uim-mozc}} is available on AUR.
 +
{{Note|This does not support kill_line feature of uim-mozc.}}
 +
You can install this from unofficial user repository. Add the following into your /etc/pacman.conf:
 
  [pnsft-pur]
 
  [pnsft-pur]
 +
SigLevel = Optional TrustAll
 
  Server = http://downloads.sourceforge.net/project/pnsft-aur/pur/$arch
 
  Server = http://downloads.sourceforge.net/project/pnsft-aur/pur/$arch
{{Note|This repo provides x86_64 packages only.}}
+
{{Note|This repo provides x86_64 packages only now.}}
You can choose install packages of Mozc as follows:
+
And refresh package database:
  # pacman -S mozc-im (Or mozc-im-svn / mozc-im-ut)
+
# pacman -Syy
 +
You can choose install packages specifying group name as follows:
 +
  # pacman -S mozc-im
 
Or, specify package names directly. For example:
 
Or, specify package names directly. For example:
  # pacman -S uim-mozc-svn emacs-mozc-svn
+
  # pacman -S uim-mozc
  
===== Compiling Mozc for uim using PKGBUILD =====
+
===== mozc-ut and mozc-svn =====
====== Prepare building Mozc ======
+
Mozc requires the following packages to be built in addition to its depending packages:
+
*Common
+
**{{Pkg|pkg-config}}
+
**{{Pkg|python2}}
+
**{{AUR|zinnia}} ''(AUR)''
+
*mozc-svn
+
**{{Pkg|subversion}}
+
*mozc-ut
+
**{{Pkg|ruby}}
+
Install {{AUR|zinnia}} from [[AUR]] before building Mozc.
+
  
====== Edit PKGBUILD ======
+
{{AUR|mozc-ut}} and {{AUR|mozc-svn}} can be built uim-mozc.
First, you get {{AUR|mozc-svn}} or {{AUR|mozc-ut}} tarball from the AUR and edit the PKGBUILD to enable uim-mozc. That is, uncomment {{Ic|_uim_mozc}} line and you can comment out {{Ic|_ibus_mozc}} line to disable ibus module if unnecessary:
+
{{Note|mozc-ut can work with {{AUR|uim-mozc}}.}}
## You can choose the input method framework to use either ibus, uim or both.
+
To build uim-mozc, edit PKGBUILD like follow, i,e. uncomment {{Ic|1=_uim_mozc=}} line:
  ## If you will be not using ibus, comment out below.
+
  ## If you will not be using ibus, comment out below.
  #_ibus_mozc="yes"
+
  _ibus_mozc="yes"
 
  ## If you will be using uim, uncomment below.
 
  ## If you will be using uim, uncomment below.
 
  _uim_mozc="yes"
 
  _uim_mozc="yes"
If you will be using mozc.el on Emacs instead of uim.el, uncomment {{Ic|_emacs_mozc}} line.
+
## If applying patch for uim-mozc fails, try to uncomment below.
## If you will be using mozc.el on Emacs, uncomment below.
+
  #_kill_kill_line="yes"
_emacs_mozc="yes"
+
## This will disable the 'kill-line' function of uim-mozc.
 +
{{Tip|If you will never be using ibus-mozc, comment out the {{Ic|1=_ibus_mozc=}} line.}}
  
====== Build and install ======
+
===== Registering Mozc =====
Finally, build and install:
+
$ makepkg -s -i
+
  
===== Re-register Mozc on uim =====
+
{{Warning|You '''must''' run the following command whenever you upgrade or (re-)install uim.<br/>
You '''must''' run the following command whenever you upgrade or (re-)install uim.
+
  # uim-module-manager --register mozc}}
  # uim-module-manager --register mozc
+
  
===== Tips =====
+
==== Google CGI API for Japanese input ====
====== Launching Mozc tools from commandline ======
+
The followings are commands to launch mozc tools.
+
* Mozc property:{{bc|1=$ /usr/lib/mozc/mozc_tool --mode=config_dialog}}
+
* Mozc Dictionary Tool:{{bc|1=$ /usr/lib/mozc/mozc_tool --mode=dictionary_tool}}
+
* Mozc word register:{{bc|1=$ /usr/lib/mozc/mozc_tool --mode=word_register}}
+
* Mozc hand writing tool:{{bc|1=$ /usr/lib/mozc/mozc_tool --mode=hand_writing}}
+
* Mozc character palette:{{bc|1=$ /usr/lib/mozc/mozc_tool --mode=character_palette}}
+
  
====== Use CapsLock as Eisu_toggle key on ASCII layout keyboard ======
+
[http://www.google.co.jp/ime/cgiapi.html Google CGI API for Japanese Input] (Google-CGIAPI-Jp) is CGI service to provide Japanese conversion on the Internet by Google. It can be used on [http://www.google.com/transliterate web browser]. Its conversion engine seems to be equivalent to Google Japanese Input, so conversion quality is probably better than Mozc.
Most of the preset keymap styles of Mozc, command 'ToggleAlphanumericMode' on 'Composition' mode is assigned to Eisu (Eisu_toggle), Hiragana/Katakana or Muhenkan key, but the ASCII keyboard has none of them.
+
  
One of the solution for it is to use CapsLock key as Eisu_toggle (Mozc does not recognize CapsLock key). The following is way to assign the Eisu_toggle to CapsLock (without any modifier keys) and the Caps_Lock to Shift + CapsLock, like OADG keyboard layout.
+
{{Note|This service sends/receives preedits and candidates as plain text (as of 2012-09).}}
{{Warning|This way affects to desktop wide.}}
+
  
Edit the {{Ic|~/.Xmodmap}} as follows:
+
You can use it via uim. Choose "Google-CGIAPI-Jp" on uim-im-switcher-gtk/gtk3/qt4 or uim-pref-gtk/gtk3/qt4.
keycode 66 = Eisu_toggle Caps_Lock
+
clear Lock
+
  
 
== Settings ==
 
== Settings ==
 +
 
Add the followings to ~/.[[xprofile]], ~/.[[xinitrc]] or ~/.xsession:
 
Add the followings to ~/.[[xprofile]], ~/.[[xinitrc]] or ~/.xsession:
 +
 
=== Environment variables ===
 
=== Environment variables ===
 +
 
  export GTK_IM_MODULE='uim'
 
  export GTK_IM_MODULE='uim'
 
  export QT_IM_MODULE='uim'
 
  export QT_IM_MODULE='uim'
 
  uim-xim &
 
  uim-xim &
  export XMODIFIERS=@im='uim'
+
  export XMODIFIERS='@im=uim'
 +
 
 +
{{Note|The variables should be exported before starting your desktop environment, i.e. before "exec startxfce4" or similar.}}
  
 
=== Toolbar utilities ===
 
=== Toolbar utilities ===
 +
 
If you want to use UimToolbar utilities which shows and controls uim mode, add '''one''' of the followings, too.
 
If you want to use UimToolbar utilities which shows and controls uim mode, add '''one''' of the followings, too.
  
 
==== uim-toolbar-gtk/qt ====
 
==== uim-toolbar-gtk/qt ====
 +
 
Using toolbar appears as a window.
 
Using toolbar appears as a window.
  
For Gtk2:
+
For GTK+ 2:
 
  uim-toolbar-gtk &
 
  uim-toolbar-gtk &
For Gtk3:
+
For GTK+ 3:
 
  uim-toolbar-gtk3 &
 
  uim-toolbar-gtk3 &
For Qt:
+
For Qt4:
 
  uim-toolbar-qt4 &
 
  uim-toolbar-qt4 &
  
 
==== uim-toolbar-gtk-systray ====
 
==== uim-toolbar-gtk-systray ====
 +
 
Using toolbar for system tray.
 
Using toolbar for system tray.
  
For Gtk2:
+
For GTK+ 2:
 
  uim-toolbar-gtk-systray &
 
  uim-toolbar-gtk-systray &
For Gtk3:
+
For GTK+ 3:
 
  uim-toolbar-gtk3-systray &
 
  uim-toolbar-gtk3-systray &
  
 
==== Panel applet ====
 
==== Panel applet ====
 +
 
Or, if you use GNOME, KDE or Xfce, you can use uim-toolbar panel applet (Xfce requires xfce4-xfapplet-plugin to use uim-applet-gnome).
 
Or, if you use GNOME, KDE or Xfce, you can use uim-toolbar panel applet (Xfce requires xfce4-xfapplet-plugin to use uim-applet-gnome).
  
 
=== uim preferences ===
 
=== uim preferences ===
 +
 
Configure uim preferences by running :
 
Configure uim preferences by running :
 
  $ uim-pref-gtk (Or, uim-pref-gtk3/uim-pref-qt4)
 
  $ uim-pref-gtk (Or, uim-pref-gtk3/uim-pref-qt4)
which brings forth a GUI.<br />
+
which brings forth a GUI.
Choose {{Ic|"Anthy"}}, {{Ic|"Anthy (UTF-8)"}} or {{Ic|"Mozc"}} for 'Default input method'.
+
 
 +
Choose your preferring input method as 'Default input method'.
 
{{Note|Mozc will be not listed in 'Default input method' at first time so you will need to add it into 'Enabled input methods' to use.}}
 
{{Note|Mozc will be not listed in 'Default input method' at first time so you will need to add it into 'Enabled input methods' to use.}}
  
 +
You can run {{ic|uim-xim}} or restart X to test your settings.
  
You can run {{Ic|uim-xim}} or restart X to test your settings.<br/>
 
 
Provided everything went well you should be able to input Japanese in X.
 
Provided everything went well you should be able to input Japanese in X.
 
お疲れ様です!
 
  
 
=== Input Japanese on Emacs ===
 
=== Input Japanese on Emacs ===
This section describes using [[#Using uim.el|uim.el]] (by uim), [[#Using mozc.el|mozc.el]] (by Mozc) and [[#Using anthy.el|anthy.el]] (by Anthy).
 
  
==== Using uim.el ====
 
 
uim provides uim.el the bridge software between Emacs and uim. Here is a sample to use uim on Emacs with utf-8 encoding.  
 
uim provides uim.el the bridge software between Emacs and uim. Here is a sample to use uim on Emacs with utf-8 encoding.  
  
 
Please see [http://code.google.com/p/uim/wiki/UimEl Official wiki] for more detail.
 
Please see [http://code.google.com/p/uim/wiki/UimEl Official wiki] for more detail.
  
===== LEIM or minor-mode =====
+
==== LEIM or minor-mode ====
 +
 
 
You can call uim.el from Emacs in two ways; directly or with the LEIM (Library of Emacs Input Method) framework. Though settings of them are different, basic functions are same. If you want to switch between uim.el and other Emacs IMs frequently, you should use LEIM framework.
 
You can call uim.el from Emacs in two ways; directly or with the LEIM (Library of Emacs Input Method) framework. Though settings of them are different, basic functions are same. If you want to switch between uim.el and other Emacs IMs frequently, you should use LEIM framework.
  
====== Settings for the minor-mode ======
+
===== Settings for the minor-mode =====
 +
 
 
If you will be using on minor-mode, write the following settings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
If you will be using on minor-mode, write the following settings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
  ;; read uim.el
 
  ;; read uim.el
Line 261: Line 230:
 
  (global-set-key "\C-\\" 'uim-mode)
 
  (global-set-key "\C-\\" 'uim-mode)
  
====== Settings for the LEIM ======
+
===== Settings for the LEIM =====
 +
 
 
If you will be using via LEIM, write the following settings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing and choose default input method.
 
If you will be using via LEIM, write the following settings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing and choose default input method.
 
  ;; read uim.el with LEIM initializing
 
  ;; read uim.el with LEIM initializing
Line 267: Line 237:
 
   
 
   
 
  ;; set default IM. Uncomment the one of the followings.
 
  ;; set default IM. Uncomment the one of the followings.
  ;(setq default-input-method "japanese-anthy-utf8-uim") ; Anthy (UTF-8)
+
  ;(setq default-input-method "japanese-anthy-utf8-uim")       ; Anthy (UTF-8)
  ;(setq default-input-method "japanese-mozc-uim")       ; Mozc
+
;(setq default-input-method "japanese-google-cgiapi-jp-uim")  ; Google-CGIAPI-Jp
 +
  ;(setq default-input-method "japanese-mozc-uim")             ; Mozc
 +
 
 +
==== Preferred character encoding ====
  
===== Preferred character encoding =====
 
 
uim.el uses euc-jp character encoding by default. To set UTF-8 as preferred encodings, add the followings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
uim.el uses euc-jp character encoding by default. To set UTF-8 as preferred encodings, add the followings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
  ;; Set UTF-8 as preferred character encoding (default is euc-jp).
 
  ;; Set UTF-8 as preferred character encoding (default is euc-jp).
Line 278: Line 250:
 
                     uim-lang-code-alist)))
 
                     uim-lang-code-alist)))
  
===== Enable inline candidates displaying mode by default =====
+
==== Enable inline candidates displaying mode by default ====
 +
 
 
The inline candidates displaying mode displays conversion candidates just below (or above) preedit text vertically instead of echo area. If you want to enable inline candidates displaying mode by default, write as follows.
 
The inline candidates displaying mode displays conversion candidates just below (or above) preedit text vertically instead of echo area. If you want to enable inline candidates displaying mode by default, write as follows.
 
  ;; set inline candidates displaying mode as default
 
  ;; set inline candidates displaying mode as default
 
  (setq uim-candidate-display-inline t)
 
  (setq uim-candidate-display-inline t)
  
===== Set Hiragana input mode by default =====
+
==== Set Hiragana input mode by default ====
 +
 
 
To set Hiragana input mode at activting uim, add the settings like follows:
 
To set Hiragana input mode at activting uim, add the settings like follows:
  
 
  ;; Set Hiragana input mode at activating uim.
 
  ;; Set Hiragana input mode at activating uim.
  (setq uim-default-im-prop '("action_anthy_utf8_hiragana" "action_mozc_hiragana"))
+
  (setq uim-default-im-prop '("action_anthy_utf8_hiragana"
 +
                            "action_google-cgiapi-jp_hiragana"
 +
                            "action_mozc_hiragana"))
 +
 
 +
==== Ignoring C-SPC on uim.el ====
  
===== Ignoring C-SPC on uim.el =====
 
 
When you are assigning activation/deactivation of input method to C-SPC, C-SPC is stolen to switch input mode by uim.el while it is activated. To prevent the stealing and use for set-mark-command, add the followings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
When you are assigning activation/deactivation of input method to C-SPC, C-SPC is stolen to switch input mode by uim.el while it is activated. To prevent the stealing and use for set-mark-command, add the followings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
  (add-hook 'uim-load-hook
 
  (add-hook 'uim-load-hook
Line 295: Line 272:
 
               (define-key uim-mode-map [67108896] nil)
 
               (define-key uim-mode-map [67108896] nil)
 
               (define-key uim-mode-map [0] nil)))
 
               (define-key uim-mode-map [0] nil)))
 
==== Using mozc.el ====
 
If you use Mozc, you can use mozc.el. Write the following settings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
(require 'mozc)  ; or (load-file "/path/to/mozc.el")
 
(setq default-input-method "japanese-mozc")
 
mozc.el provides "overlay" mode in the styles of showing candidates (from mozc r77) similar to the inline candidates displaying mode of uim.el. If you want to use overlay mode, add the following.
 
(setq mozc-candidate-style 'overlay)
 
 
==== Using anthy.el ====
 
If you use Anthy, you can use anthy.el. Write the following settings into your {{Ic|.emacs.d/init.el}} or some other file for Emacs customizing.
 
(load-library "anthy")
 
(setq default-input-method "japanese-anthy")
 
{{Note|anthy.el may not support UTF-8 properly.}}
 
  
 
==== Disabling XIM on Emacs ====
 
==== Disabling XIM on Emacs ====
 +
 
When you are using input method on your desktop and assigning activation/deactivation of input method to C-SPC, you will be not able to use C-SPC/C-@ as set-mark-command on Emacs. To avoid this problem, add the following into your {{Ic|~/.Xresources}} or {{Ic|~/.Xdefaults}}. xim will be disabled on Emacs.
 
When you are using input method on your desktop and assigning activation/deactivation of input method to C-SPC, you will be not able to use C-SPC/C-@ as set-mark-command on Emacs. To avoid this problem, add the following into your {{Ic|~/.Xresources}} or {{Ic|~/.Xdefaults}}. xim will be disabled on Emacs.
 
  Emacs*UseXIM: false
 
  Emacs*UseXIM: false
  
 
== Troubleshooting ==
 
== Troubleshooting ==
 +
 +
=== Set the GTK_IM_MODULE variable, but uim still not works with GTK+ 2 applications ===
 +
 +
In case you already set the GTK_IM_MODULE environmental variable, but uim still not works with GTK+ 2 applications, you need to specify the location of gtk.immodules, which is created by and can be generated with {{Ic|gtk-query-immodules-2.0}}.
 +
 +
The default location is {{Ic|/etc/gtk-2.0/gtk.immodules}} for GTK+ 2.
 +
 +
You can do this with either the GTK_IM_MODULE_FILE variable (''not recommended'', it causes GTK+ 3 applications to see incompatible modules) or the im_module_file setting (''recommended'').
 +
 +
Add the following to {{Ic|/etc/gtk-2.0/gtkrc}} or {{Ic|~/.gtkrc-2.0}}:
 +
 +
  im_module_file "/etc/gtk-2.0/gtk.immodules"
 +
 
=== Cannot input Japanese on Opera ===
 
=== Cannot input Japanese on Opera ===
 +
 
If you use Opera and cannot input Japanese with uim, try to edit environment variable as follows:
 
If you use Opera and cannot input Japanese with uim, try to edit environment variable as follows:
 +
Make sure to add follows in the beginning of /usr/bin/opera.
 +
 +
export XMODIFIERS='@im=uim'
 
  export QT_IM_MODULE='xim'
 
  export QT_IM_MODULE='xim'
 +
 +
=== Cannot type a consonant in Zenkaku mode ===
 +
 +
If you cannot type a consonant in Zenkaku mode, add follows to your config file.
 +
 +
    e.g.  vi ~/.uim.d/customs/custom-google-cgiapi-jp.scm
 +
   
 +
    (define ja-rk-rule-hoge
 +
    (map
 +
    (lambda (c)
 +
    (list (cons (list c) ()) (list c c c)))
 +
    '("b" "c" "d" "f" "g" "h" "j" "k" "l" "m"
 +
    "p" "q" "r" "s" "t" "v" "w" "x" "y" "z"
 +
    "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
 +
    "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")))
 +
    (if (symbol-bound? 'ja-rk-rule-hoge)
 +
    (set! ja-rk-rule (append ja-rk-rule-hoge ja-rk-rule)))
  
 
=== uim-toolbar-gtk-systray: tray icon is crushed ===
 
=== uim-toolbar-gtk-systray: tray icon is crushed ===
 +
 
Though some of DE, WM or panel application  may provide only one icon space per application on system-tray/notification-area, uim-toolbar-gtk-systray displays some icons on it by default so those icons are crushed. Choose just one of them to solve it. The steps to display only 'Input mode' icon for example as follows:
 
Though some of DE, WM or panel application  may provide only one icon space per application on system-tray/notification-area, uim-toolbar-gtk-systray displays some icons on it by default so those icons are crushed. Choose just one of them to solve it. The steps to display only 'Input mode' icon for example as follows:
 
# Run {{Ic|uim-pref-gtk}}.
 
# Run {{Ic|uim-pref-gtk}}.
Line 324: Line 324:
 
# Take the all checkmarks off.
 
# Take the all checkmarks off.
 
# Click 'Anthy', 'Anthy (UTF-8)' or 'Mozc' which you are using on 'Group' list.
 
# Click 'Anthy', 'Anthy (UTF-8)' or 'Mozc' which you are using on 'Group' list.
# Click Edit button in 'Toolbar' box -> 'Enable toolbar buttons' line.
+
# Click Edit button in 'Toolbar' box > 'Enable toolbar buttons' line.
 
# Enable only 'Input mode' and click 'Close' button.
 
# Enable only 'Input mode' and click 'Close' button.
 
# Click 'OK' button to close uim-pref-gtk.
 
# Click 'OK' button to close uim-pref-gtk.
Line 330: Line 330:
  
 
=== I use darker theme, I cannot read the uim mode icons ===
 
=== I use darker theme, I cannot read the uim mode icons ===
 +
 
You can choose icons for darker background (uim 1.6.0 or later).
 
You can choose icons for darker background (uim 1.6.0 or later).
 
# Run uim-perf-gtk
 
# Run uim-perf-gtk
Line 335: Line 336:
 
# Check 'Use icon for dark background'.
 
# Check 'Use icon for dark background'.
  
== Useful literature ==
+
== See also ==
 +
 
 
;uim
 
;uim
 
:[http://code.google.com/p/uim/wiki/OfficialUserDocument uim official document]
 
:[http://code.google.com/p/uim/wiki/OfficialUserDocument uim official document]

Revision as of 20:04, 12 November 2013

This page explains how to get the Japanese input to work using uim.

If you use SCIM, see Smart Common Input Method platform.

If you use IBus, see Ibus.

Installation

You need the following packages to input Japanese.

  • Japanese fonts
  • Japanese input method (Kana to Kanji conversion engine)
  • Input method framework: uim

Japanese fonts

see also Fonts and Font Configuration for configuration or more detail.

Recommended Japanese fonts are as follows.

A high quality and formal style opensource font set including Gothic (sans-serif) and Mincho (serif) glyphs. Default font of openSUSE-ja.
Default Gothic font of Debian-ja, Fedora-ja, Vine Linux, et al.
Default Gothic font of Mandriva Linux ja environment.

If you want to show 2channel Shift JIS art properly, use one of the following fonts:

uim

Using pacman

Install uim from the official repositories.

Compiling uim from source using PKGBUILD

If you want to build uim with your configurationin, you can compile from source, using ABS for istance. See official wiki for all configure options.

In Arch official repositories, uim is built with the following custom configuration (as of 1.8.6):

  • --with-anthy-utf8 - Enable Anthy(UTF-8) support
  • --with-qt4-immodule - Build Qt4 immodule
  • --with-qt4 - Build uim-tools for Qt4

If you want KDE4 plasma widget, install automoc4 for making dependency, and add --enable-kde4-applet option to PKGBUILD file.

Input method

Anthy

Anthy is one of the most popular Japanese input methods in the open source world. However, it has not been maintained for a long time. Debian succeeds it from May 2010.

Install anthy from the official repositories.

Extra dictionary

Anthy's default dictionary does not include several characters which are not specified on EUC-JP (JIS X 0208) such as "①", "♥", etc. alt-cannadic provides extra dictionaries including those characters.

Get alt-cannadic dictionary and put them under your ~/.anthy/imported_words_default.d.

$ tar jxvf alt-cannadic-091230.tar.bz2
$ mkdir ~/.anthy/imported_words_default.d (if not exist)
$ cp alt-cannadic-091230/extra/*.t ~/.anthy/imported_words_default.d/

Please see official wiki for more detail (Japanese).

Warning: If you will be using this extra dictionary, choose Anthy (UTF-8) for default input method on uim.

Modified Anthy (anthy-ut)

Modified Anthy is a set of patches and huge extended dictionaries which aims to improve the Kana to Kanji conversion quality of original Anthy.

Modified Anthy consists two different upstreams:

  • Patched source of Anthy by G-HAL
  • Huge extended dictionalies by UTSUMI
Warning:
  • Modified Anthy applies to only Anthy (UTF-8). So you have to choose Anthy (UTF-8) for default input method on uim.
  • Modified Anthy does not have compatibility of the dictionaries and learning data with original Anthy.
Compiling modified Anthy using PKGBUILD

Modified Anthy is available on AUR named anthy-utAUR.

Get anthy-ut tarball and makepkg to make and install package:

$ wget https://aur.archlinux.org/packages/anthy-ut/anthy-ut.tar.gz
$ tar xvf anthy-ut.tar.gz
$ cd anthy-ut
$ makepkg -s -i

If you already use original Anthy, you have to convert the existing learning data format.

$ rm ~/.anthy/last-record1_*.bin
$ anthy-agent --update-base-record
$ rm ~/.anthy/last-record1_*.bin
$ anthy-agent --update-base-record

(Though this step repeats the same commands twice, it is not mistypes.)

Anthy Kaomoji

Anthy Kaomoji is a modified version of Anthy that converts Hiragana text to Kana Kanji mixed text and has emoticon (顔文字) and 2ch dictionaries. It can be found in the AUR (anthy-kaomojiAUR).

Mozc

See Mozc.

Mozc is a Japanese Input Method Editor (IME) designed for multi-platform such as Chromium OS, Windows, Mac and Linux which originates from Google Japanese Input.

Though MozcAUR adapts to only ibus input method framework, macuim provides uim-mozc plugin.

Mozc (Vanilla)

uim-mozcAUR is available on AUR.

Note: This does not support kill_line feature of uim-mozc.

You can install this from unofficial user repository. Add the following into your /etc/pacman.conf:

[pnsft-pur]
SigLevel = Optional TrustAll
Server = http://downloads.sourceforge.net/project/pnsft-aur/pur/$arch
Note: This repo provides x86_64 packages only now.

And refresh package database:

# pacman -Syy

You can choose install packages specifying group name as follows:

# pacman -S mozc-im

Or, specify package names directly. For example:

# pacman -S uim-mozc
mozc-ut and mozc-svn

mozc-utAUR and mozc-svnAUR can be built uim-mozc.

Note: mozc-ut can work with uim-mozcAUR.

To build uim-mozc, edit PKGBUILD like follow, i,e. uncomment _uim_mozc= line:

## If you will not be using ibus, comment out below.
_ibus_mozc="yes"
## If you will be using uim, uncomment below.
_uim_mozc="yes"
## If applying patch for uim-mozc fails, try to uncomment below.
#_kill_kill_line="yes"
## This will disable the 'kill-line' function of uim-mozc.
Tip: If you will never be using ibus-mozc, comment out the _ibus_mozc= line.
Registering Mozc
Warning: You must run the following command whenever you upgrade or (re-)install uim.
# uim-module-manager --register mozc

Google CGI API for Japanese input

Google CGI API for Japanese Input (Google-CGIAPI-Jp) is CGI service to provide Japanese conversion on the Internet by Google. It can be used on web browser. Its conversion engine seems to be equivalent to Google Japanese Input, so conversion quality is probably better than Mozc.

Note: This service sends/receives preedits and candidates as plain text (as of 2012-09).

You can use it via uim. Choose "Google-CGIAPI-Jp" on uim-im-switcher-gtk/gtk3/qt4 or uim-pref-gtk/gtk3/qt4.

Settings

Add the followings to ~/.xprofile, ~/.xinitrc or ~/.xsession:

Environment variables

export GTK_IM_MODULE='uim'
export QT_IM_MODULE='uim'
uim-xim &
export XMODIFIERS='@im=uim'
Note: The variables should be exported before starting your desktop environment, i.e. before "exec startxfce4" or similar.

Toolbar utilities

If you want to use UimToolbar utilities which shows and controls uim mode, add one of the followings, too.

uim-toolbar-gtk/qt

Using toolbar appears as a window.

For GTK+ 2:

uim-toolbar-gtk &

For GTK+ 3:

uim-toolbar-gtk3 &

For Qt4:

uim-toolbar-qt4 &

uim-toolbar-gtk-systray

Using toolbar for system tray.

For GTK+ 2:

uim-toolbar-gtk-systray &

For GTK+ 3:

uim-toolbar-gtk3-systray &

Panel applet

Or, if you use GNOME, KDE or Xfce, you can use uim-toolbar panel applet (Xfce requires xfce4-xfapplet-plugin to use uim-applet-gnome).

uim preferences

Configure uim preferences by running :

$ uim-pref-gtk (Or, uim-pref-gtk3/uim-pref-qt4)

which brings forth a GUI.

Choose your preferring input method as 'Default input method'.

Note: Mozc will be not listed in 'Default input method' at first time so you will need to add it into 'Enabled input methods' to use.

You can run uim-xim or restart X to test your settings.

Provided everything went well you should be able to input Japanese in X.

Input Japanese on Emacs

uim provides uim.el the bridge software between Emacs and uim. Here is a sample to use uim on Emacs with utf-8 encoding.

Please see Official wiki for more detail.

LEIM or minor-mode

You can call uim.el from Emacs in two ways; directly or with the LEIM (Library of Emacs Input Method) framework. Though settings of them are different, basic functions are same. If you want to switch between uim.el and other Emacs IMs frequently, you should use LEIM framework.

Settings for the minor-mode

If you will be using on minor-mode, write the following settings into your .emacs.d/init.el or some other file for Emacs customizing.

;; read uim.el
(require 'uim)
;; uncomment next and comment out previous to load uim.el on-demand
;; (autoload 'uim-mode "uim" nil t)

;; key-binding for activate uim (ex. C-\)
(global-set-key "\C-\\" 'uim-mode)
Settings for the LEIM

If you will be using via LEIM, write the following settings into your .emacs.d/init.el or some other file for Emacs customizing and choose default input method.

;; read uim.el with LEIM initializing
(require 'uim-leim)

;; set default IM. Uncomment the one of the followings.
;(setq default-input-method "japanese-anthy-utf8-uim")        ; Anthy (UTF-8)
;(setq default-input-method "japanese-google-cgiapi-jp-uim")  ; Google-CGIAPI-Jp
;(setq default-input-method "japanese-mozc-uim")              ; Mozc

Preferred character encoding

uim.el uses euc-jp character encoding by default. To set UTF-8 as preferred encodings, add the followings into your .emacs.d/init.el or some other file for Emacs customizing.

;; Set UTF-8 as preferred character encoding (default is euc-jp).
(setq uim-lang-code-alist
      (cons '("Japanese" "Japanese" utf-8 "UTF-8")
           (delete (assoc "Japanese" uim-lang-code-alist) 
                   uim-lang-code-alist)))

Enable inline candidates displaying mode by default

The inline candidates displaying mode displays conversion candidates just below (or above) preedit text vertically instead of echo area. If you want to enable inline candidates displaying mode by default, write as follows.

;; set inline candidates displaying mode as default
(setq uim-candidate-display-inline t)

Set Hiragana input mode by default

To set Hiragana input mode at activting uim, add the settings like follows:

;; Set Hiragana input mode at activating uim.
(setq uim-default-im-prop '("action_anthy_utf8_hiragana"
                            "action_google-cgiapi-jp_hiragana"
                            "action_mozc_hiragana"))

Ignoring C-SPC on uim.el

When you are assigning activation/deactivation of input method to C-SPC, C-SPC is stolen to switch input mode by uim.el while it is activated. To prevent the stealing and use for set-mark-command, add the followings into your .emacs.d/init.el or some other file for Emacs customizing.

(add-hook 'uim-load-hook
          '(lambda ()
             (define-key uim-mode-map [67108896] nil)
             (define-key uim-mode-map [0] nil)))

Disabling XIM on Emacs

When you are using input method on your desktop and assigning activation/deactivation of input method to C-SPC, you will be not able to use C-SPC/C-@ as set-mark-command on Emacs. To avoid this problem, add the following into your ~/.Xresources or ~/.Xdefaults. xim will be disabled on Emacs.

Emacs*UseXIM: false

Troubleshooting

Set the GTK_IM_MODULE variable, but uim still not works with GTK+ 2 applications

In case you already set the GTK_IM_MODULE environmental variable, but uim still not works with GTK+ 2 applications, you need to specify the location of gtk.immodules, which is created by and can be generated with gtk-query-immodules-2.0.

The default location is /etc/gtk-2.0/gtk.immodules for GTK+ 2.

You can do this with either the GTK_IM_MODULE_FILE variable (not recommended, it causes GTK+ 3 applications to see incompatible modules) or the im_module_file setting (recommended).

Add the following to /etc/gtk-2.0/gtkrc or ~/.gtkrc-2.0:

 im_module_file "/etc/gtk-2.0/gtk.immodules"

Cannot input Japanese on Opera

If you use Opera and cannot input Japanese with uim, try to edit environment variable as follows: Make sure to add follows in the beginning of /usr/bin/opera.

export XMODIFIERS='@im=uim'
export QT_IM_MODULE='xim'

Cannot type a consonant in Zenkaku mode

If you cannot type a consonant in Zenkaku mode, add follows to your config file.

   e.g.  vi ~/.uim.d/customs/custom-google-cgiapi-jp.scm
    
   (define ja-rk-rule-hoge
   (map
   (lambda (c)
   (list (cons (list c) ()) (list c c c)))
   '("b" "c" "d" "f" "g" "h" "j" "k" "l" "m"
   "p" "q" "r" "s" "t" "v" "w" "x" "y" "z"
   "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
   "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")))
   (if (symbol-bound? 'ja-rk-rule-hoge)
   (set! ja-rk-rule (append ja-rk-rule-hoge ja-rk-rule)))

uim-toolbar-gtk-systray: tray icon is crushed

Though some of DE, WM or panel application may provide only one icon space per application on system-tray/notification-area, uim-toolbar-gtk-systray displays some icons on it by default so those icons are crushed. Choose just one of them to solve it. The steps to display only 'Input mode' icon for example as follows:

  1. Run uim-pref-gtk.
  2. Click 'Toolbar' on 'Group' list.
  3. Take the all checkmarks off.
  4. Click 'Anthy', 'Anthy (UTF-8)' or 'Mozc' which you are using on 'Group' list.
  5. Click Edit button in 'Toolbar' box > 'Enable toolbar buttons' line.
  6. Enable only 'Input mode' and click 'Close' button.
  7. Click 'OK' button to close uim-pref-gtk.

The tray icon will be displayed "あ" (Hiragana mode) or "ー" (Direct mode).

I use darker theme, I cannot read the uim mode icons

You can choose icons for darker background (uim 1.6.0 or later).

  1. Run uim-perf-gtk
  2. Click 'Toolbar' on 'Group' list.
  3. Check 'Use icon for dark background'.

See also

uim
uim official document
uim on wikibooks
Fonts
Japanese fonts showcase
modified Japanese fonts