It is much easier to use xyaku if you convert your system to
UTF-8. See my UTF-8 page. Just convert the
edict dictionary itself from EUC-JP encoding to UTF-8 using
iconv, and xyaku will work perfectly. Select a word
in any program, including (modern versions of) Mozilla, and xyaku will
display the translation(s), because copy/paste from Mozilla does not produce
the ‘quoted’ form any more (e.g. \x{3042} for あ).
This works OK for English words, and for Japanese words displayed traditionally, i.e. as JIS or EUC code, as for instance in kterm. However, in modern versions of Mozilla, Japanese is displayed using Unicode. If you pick, for instance, a Hiragana 'A' off the screen, you get this:
\x{3042}
instead of the EUC code for Hiragana A (which looks like
¤¢ on a Latin-1 terminal). EDICT (which is EUC coded)
cannot handle Unicode strings. This pretty much excludes using
xyaku (and other EDICT-using products, like xjdic) with
Mozilla.
Here I present a solution for xyaku which involves 2 intermediate steps:
cc -Wall -o unuquote unuquote.cand put the resulting binary in /usr/local/bin.
toKey F1 C true 0 0 0 edict.sh
The 'hotkey' for translation is now ALT-F10, one of the few keys not already claimed by KDE. The translation script is now edict2.sh (instead of edict.sh; we still have to construct edict2.sh). Also, comment out all other lines starting with Key or AutoKey. Comment out the lineKey F10 M true 0 0 0 edict2.sh
ModulePath /home/inoue/work/xyaku/addin
# target word from standard input
read target
if [ -z $target ]
then
exit 0
fi
to
# target word from standard input
read -r targetA
if [ -z $targetA ]
then
exit 0
fi
target=`echo $targetA|unuquote|lv -Tut8 -Oej|cat`
Mind the backquotes! Mind the -r option on the read command (this protects
the backslashes in the Unicode sequences). We also change the name of the
'target' string temporarily.
should work, with words selected from the Mozilla screen. It also still works with words selected from kterm. xyaku's dictionary lookup is somewhat slow -- perhaps because of these extra filters. Anyway, enjoy.LANG=ja_JP xyaku &