https://wiki.archlinux.org/api.php?action=feedcontributions&user=Nichdel&feedformat=atomArchWiki - User contributions [en]2024-03-29T11:34:29ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Input_Japanese_using_uim&diff=211844Input Japanese using uim2012-07-02T17:32:31Z<p>Nichdel: Cleaned up the writing style a bit.</p>
<hr />
<div>[[Category:Internationalization]]<br />
[[ja:Input Japanese using uim]]<br />
This page explains how to get the Japanese input to work using [http://code.google.com/p/uim/ uim].<br/><br />
If you use SCIM, see [[Smart Common Input Method platform]].<br/><br />
If you use IBus, see [[Ibus]].<br />
<br />
== Installation ==<br />
You need the following packages to input Japanese.<br />
<br />
* Japanese fonts<br />
* 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].<br />
* Input method framework: uim<br />
<br />
=== Japanese fonts ===<br />
''see also [[Fonts]] and [[Font Configuration]] for configuration or more detail.''<br />
<br />
Recommended Japanese fonts are as follows.<br />
* [http://ossipedia.ipa.go.jp/ipafont/ IPA fonts] ([[Arch User Repository|AUR]]: {{AUR|otf-ipafont}})<br />
:A high quality and formal style opensource font set including Gothic (sans-serif) and Mincho (serif) glyphs. Default font of openSUSE-ja.<br />
* [http://dicey.org/vlgothic/ VL Gothic] (AUR: {{AUR|ttf-vlgothic}})<br />
:Default Gothic font of Debian-ja, Fedora-ja, Vine Linux, et al.<br />
* [http://www.geocities.jp/ep3797/modified_fonts_01.html UmePlus Gothic] (AUR: {{AUR|ttf-umeplus}})<br />
:Default Gothic font of Mandriva Linux ja environment.<br />
<br />
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:<br />
* ipamona font (AUR: {{AUR|ttf-ipa-mona}})<br />
* Monapo font (AUR: {{AUR|ttf-monapo}})<br />
<br />
=== uim ===<br />
==== Using pacman ====<br />
Pull down the necessary things with a :<br />
# pacman -S uim<br />
<br />
==== Compiling uim from source using PKGBUILD ====<br />
For instance, if you want to build uim with your configurationin, you can compile from source.<br />
<br />
===== Arch's configuration=====<br />
In Arch official repository, uim is built with the following custom configuration (as of 1.7.1):<br />
* {{Ic|--with-anthy-utf8}} : Enable Anthy(UTF-8) support<br />
* {{Ic|--with-qt4}} : Build uim-tools for Qt<br />
<br />
Please see [http://code.google.com/p/uim/wiki/InstallUim official wiki] for all configure options.<br />
<br />
===== Steps to build=====<br />
The one of the easy way to build from source is using ABS.<br /><br />
First, install ABS:<br />
# pacman -S abs<br />
Update ABS:<br />
# abs<br />
<br />
Then, copy uim's directory to under your $HOME. For example:<br />
$ cp -R /var/abs/extra/uim ~/sources/<br />
<br />
Edit PKGBUILD.<br />
<br />
Finally, run makepkg under uim directory to make and install package:<br />
$ makepkg -s -i<br />
<br />
=== Input method ===<br />
==== Anthy ====<br />
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.<br />
<br />
To install Anthy :<br />
# pacman -S anthy<br />
<br />
===== Extra dictionary =====<br />
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.<br />
<br />
Get [http://en.sourceforge.jp/projects/alt-cannadic/releases/?package_id=6129 alt-cannadic dictionary] and put them under your {{Ic|~/.anthy/imported_words_default.d}}.<br />
$ tar jxvf alt-cannadic-091230.tar.bz2<br />
$ mkdir ~/.anthy/imported_words_default.d (if not exist)<br />
$ cp alt-cannadic-091230/extra/*.t ~/.anthy/imported_words_default.d/<br />
<br />
Please see [http://sourceforge.jp/projects/alt-cannadic/wiki/%E4%BD%BF%E3%81%84%E6%96%B9_Anthy-UTF-8 official wiki] for more detail (Japanese).<br />
<br />
{{Warning|If you will be using this extra dictionary, choose '''Anthy (UTF-8)''' for default input method on uim.}}<br />
<br />
==== Modified Anthy (anthy-ut) ====<br />
[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.<br />
<br />
Modified Anthy consists two different upstreams:<br />
* Patched source of Anthy by [http://www.fenix.ne.jp/~G-HAL/soft/nosettle/#anthy G-HAL]<br />
* Huge extended dictionalies by [http://www.geocities.jp/ep3797/anthy_dict_01.html UTSUMI]<br />
<br />
{{Warning|Modified Anthy applies to only Anthy (UTF-8). So you have to choose '''Anthy (UTF-8)''' for default input method on uim.}}<br />
{{Warning|Modified Anthy does not have compatibility of the dictionaries and learning data with original Anthy.}}<br />
<br />
===== Compiling Modified Anthy using PKGBUILD =====<br />
Modified Anthy is available on AUR named {{AUR|anthy-ut}}.<br />
<br />
Get anthy-ut tarball and makepkg to make and install package:<br />
$ wget https://aur.archlinux.org/packages/anthy-ut/anthy-ut.tar.gz<br />
$ tar xvf anthy-ut.tar.gz<br />
$ cd anthy-ut<br />
$ makepkg -s -i<br />
<br />
If you already use original Anthy, you have to convert the existing learning data format.<br />
$ rm ~/.anthy/last-record1_*.bin<br />
$ anthy-agent --update-base-record<br />
$ rm ~/.anthy/last-record1_*.bin<br />
$ anthy-agent --update-base-record<br />
(Though this step repeats the same commands twice, it is not mistypes.)<br />
<br />
==== Anthy Kaomoji ====<br />
<br />
[http://sourceforge.jp/projects/anthy/ Anthy Kaomoji] is a modified version of Anthy that converts Hiragana text to Kana Kanji mixed text and has emoticon (顔文字) and 2ch dictionaries.<br />
It can be found in the AUR ({{AUR|anthy-kaomoji}}).<br />
<br />
==== Mozc ====<br />
[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.<br />
<br />
* {{AUR|mozc-svn}}<br />
** 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.}}<br />
* {{AUR|mozc-ut}}<br />
** 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.}}<br />
<br />
Each packages consist as follows:<br />
{| class="wikitable" style="text-align:center;margin:0 2em auto"<br />
!Package !! mozc !! mozc-svn !! mozc-ut !! description<br />
|-<br />
!Group<br />
| mozc-im || mozc-im-svn || mozc-im-ut ||<br />
|-<br />
!rowspan="5" | Component<br />
| mozc || mozc-svn || mozc-ut || Server part of the Mozc<br />
|-<br />
| ibus-mozc || ibus-mozc-svn || ibus-mozc-ut || IBus engine module (optional)<br />
|-<br />
| <small>''N/A''</small> || uim-mozc-svn || uim-mozc-ut || uim plugin module (optional)<br />
|-<br />
| <small>''N/A''</small> || fcitx-mozc-svn || <small>''N/A''</small> || Fcitx module (optional)<br />
|-<br />
| emacs-mozc || emacs-mozc-svn || emacs-mozc-ut || Mozc for Emacs (optional)<br />
|}<br />
<br />
===== Using Unofficial user repository =====<br />
There is an unofficial user repository of Mozc. Add the following into /etc/pacman.conf.<br />
[pnsft-pur]<br />
Server = http://downloads.sourceforge.net/project/pnsft-aur/pur/$arch<br />
{{Note|This repo provides x86_64 packages only.}}<br />
You can choose install packages of Mozc as follows:<br />
# pacman -S mozc-im (Or mozc-im-svn / mozc-im-ut)<br />
Or, specify package names directly. For example:<br />
# pacman -S uim-mozc-svn emacs-mozc-svn<br />
<br />
===== Compiling Mozc for uim using PKGBUILD =====<br />
====== Prepare building Mozc ======<br />
Mozc requires the following packages to be built in addition to its depending packages:<br />
*Common<br />
**{{Pkg|pkg-config}}<br />
**{{Pkg|python2}}<br />
**{{AUR|zinnia}} ''(AUR)''<br />
*mozc-svn<br />
**{{Pkg|subversion}}<br />
*mozc-ut<br />
**{{Pkg|ruby}}<br />
Install {{AUR|zinnia}} from [[AUR]] before building Mozc.<br />
<br />
====== Edit PKGBUILD ======<br />
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:<br />
## You can choose the input method framework to use either ibus, uim or both.<br />
## If you will be not using ibus, comment out below.<br />
#_ibus_mozc="yes"<br />
## If you will be using uim, uncomment below.<br />
_uim_mozc="yes"<br />
If you will be using mozc.el on Emacs instead of uim.el, uncomment {{Ic|_emacs_mozc}} line.<br />
## If you will be using mozc.el on Emacs, uncomment below.<br />
_emacs_mozc="yes"<br />
<br />
====== Build and install ======<br />
Finally, build and install:<br />
$ makepkg -s -i<br />
<br />
===== Re-register Mozc on uim =====<br />
You '''must''' run the following command whenever you upgrade or (re-)install uim.<br />
# uim-module-manager --register mozc<br />
<br />
== Settings ==<br />
Add the followings to ~/.[[xprofile]], ~/.[[xinitrc]] or ~/.xsession:<br />
=== Environment variables ===<br />
export GTK_IM_MODULE='uim'<br />
export QT_IM_MODULE='uim'<br />
uim-xim &<br />
export XMODIFIERS=@im='uim'<br />
<br />
=== Toolbar utilities ===<br />
If you want to use UimToolbar utilities which shows and controls uim mode, add '''one''' of the followings, too.<br />
<br />
==== uim-toolbar-gtk/qt ====<br />
Using toolbar appears as a window.<br />
<br />
For Gtk2:<br />
uim-toolbar-gtk &<br />
For Gtk3:<br />
uim-toolbar-gtk3 &<br />
For Qt:<br />
uim-toolbar-qt4 &<br />
<br />
==== uim-toolbar-gtk-systray ====<br />
Using toolbar for system tray.<br />
<br />
For Gtk2:<br />
uim-toolbar-gtk-systray &<br />
For Gtk3:<br />
uim-toolbar-gtk3-systray &<br />
<br />
==== Panel applet ====<br />
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).<br />
<br />
=== uim preferences ===<br />
Configure uim preferences by running :<br />
$ uim-pref-gtk (Or, uim-pref-gtk3/uim-pref-qt4)<br />
which brings forth a GUI.<br /><br />
Choose {{Ic|"Anthy"}}, {{Ic|"Anthy (UTF-8)"}} or {{Ic|"Mozc"}} for 'Default input method'.<br />
{{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.}}<br />
<br />
<br />
You can run {{Ic|uim-xim}} or restart X to test your settings.<br/><br />
Provided everything went well you should be able to input Japanese in X.<br />
<br />
お疲れ様です!<br />
<br />
=== Input Japanese on Emacs ===<br />
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). <br />
<br />
==== Using uim.el ====<br />
uim provides uim.el the bridge software between Emacs and uim. Here is a sample to use uim on Emacs with utf-8 encoding. <br />
<br />
Please see [http://code.google.com/p/uim/wiki/UimEl Official wiki] for more detail.<br />
<br />
===== LEIM or minor-mode =====<br />
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.<br />
<br />
====== Settings for the minor-mode ======<br />
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.<br />
;; read uim.el<br />
(require 'uim)<br />
;; uncomment next and comment out previous to load uim.el on-demand<br />
;; (autoload 'uim-mode "uim" nil t)<br />
<br />
;; key-binding for activate uim (ex. C-\)<br />
(global-set-key "\C-\\" 'uim-mode)<br />
<br />
====== Settings for the LEIM ======<br />
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.<br />
;; read uim.el with LEIM initializing<br />
(require 'uim-leim)<br />
<br />
;; set default IM. Uncomment the one of the followings.<br />
;(setq default-input-method "japanese-anthy-utf8-uim") ; Anthy (UTF-8)<br />
;(setq default-input-method "japanese-mozc-uim") ; Mozc<br />
<br />
===== Preferred character encoding =====<br />
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.<br />
;; Set UTF-8 as preferred character encoding (default is euc-jp).<br />
(setq uim-lang-code-alist<br />
(cons '("Japanese" "Japanese" utf-8 "UTF-8")<br />
(delete (assoc "Japanese" uim-lang-code-alist) <br />
uim-lang-code-alist)))<br />
<br />
===== Enable inline candidates displaying mode by default =====<br />
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.<br />
;; set inline candidates displaying mode as default<br />
(setq uim-candidate-display-inline t)<br />
<br />
===== Set Hiragana input mode by default =====<br />
To set Hiragana input mode at activting uim, add the settings like follows:<br />
<br />
;; Set Hiragana input mode at activating uim.<br />
(setq uim-default-im-prop '("action_anthy_utf8_hiragana" "action_mozc_hiragana"))<br />
<br />
===== Ignoring C-SPC on uim.el =====<br />
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.<br />
(add-hook 'uim-load-hook<br />
'(lambda ()<br />
(define-key uim-mode-map [67108896] nil)<br />
(define-key uim-mode-map [0] nil)))<br />
<br />
==== Using mozc.el ====<br />
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.<br />
(require 'mozc) ; or (load-file "/path/to/mozc.el")<br />
(setq default-input-method "japanese-mozc")<br />
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.<br />
(setq mozc-candidate-style 'overlay)<br />
<br />
==== Using anthy.el ====<br />
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.<br />
(load-library "anthy")<br />
(setq default-input-method "japanese-anthy")<br />
{{Note|anthy.el may not support UTF-8 properly.}}<br />
<br />
==== Disabling XIM on Emacs ====<br />
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.<br />
Emacs*UseXIM: false<br />
<br />
== Troubleshooting ==<br />
=== Cannot input Japanese on Opera ===<br />
If you use Opera and cannot input Japanese with uim, try to edit environment variable as follows:<br />
export QT_IM_MODULE='xim'<br />
<br />
=== uim-toolbar-gtk-systray: tray icon is crushed ===<br />
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:<br />
# Run {{Ic|uim-pref-gtk}}.<br />
# Click 'Toolbar' on 'Group' list.<br />
# Take the all checkmarks off.<br />
# Click 'Anthy', 'Anthy (UTF-8)' or 'Mozc' which you are using on 'Group' list.<br />
# Click Edit button in 'Toolbar' box -> 'Enable toolbar buttons' line.<br />
# Enable only 'Input mode' and click 'Close' button.<br />
# Click 'OK' button to close uim-pref-gtk.<br />
The tray icon will be displayed "あ" (Hiragana mode) or "ー" (Direct mode).<br />
<br />
=== I use darker theme, I cannot read the uim mode icons ===<br />
You can choose icons for darker background (uim 1.6.0 or later).<br />
# Run uim-perf-gtk<br />
# Click 'Toolbar' on 'Group' list.<br />
# Check 'Use icon for dark background'.<br />
<br />
== Useful literature ==<br />
;uim<br />
:[http://code.google.com/p/uim/wiki/OfficialUserDocument uim official document]<br />
:[http://en.wikibooks.org/wiki/Uim uim on wikibooks]<br />
<br />
;Fonts<br />
:[http://www.geocities.jp/ep3797/japanese_fonts.html Japanese fonts showcase]<br />
:[http://www.geocities.jp/ep3797/modified_fonts_01.html modified Japanese fonts]</div>Nichdel