Topic: Fast Japanese or Chinese dictionary
I've had a bit of translation to do lately, and used this a lot. Select a couple of kanji characters somewhere on your desktop, hit Win+J (or whatever) and in a flash up will pop a window with the translation, examples etc. Here's how:
Get Dillo. I've mentioned this browser before - it's a very feature-light, unbelievably fast browser that's perfect for jobs like this. (If you'd rather use a terminal browser like elinks you probably know how to adapt these ideas.) It's not in the repos, possibly because the ssl is insecure, but that needn't bother us here. You can get a .deb file for Ubuntu Lucid here, or for the ssl-enabled version here. Both of these work fine for me on Statler - the ssl version enables you to read https sites like the Ubuntu wiki, but don't use it for internet banking!!
Once you've got Dillo you'll need to edit the config file, ~/.dillo/dillorc, a bit. At the very least you have to set the font to one that supports Japanese! I like VL PGothic but you may have your own favourite. So I have these two lines:
font_sans_serif="VL PGothic"
font_serif="VL PGothic"It's also a good idea to disable css - it slows things down for no particular benefit:
# Change this if you want to disable loading of CSS stylesheets initially.
# (While browsing, this can be changed from the tools/settings menu.)
load_stylesheets=NO
# Change this if you want to disable parsing of embedded CSS initially.
# (While browsing, this can be changed from the tools/settings menu.)
parse_embedded_css=NOHave a look through the file to see if there's anything else you want to change.
You'll also need xsel to read in from the selection. It's in the repositories.
OK now here's the script that uses our new Dillo:
#!/bin/bash
# query the online EDICT
BROWSER=dillo # your fastest browser: dillo recommended
if [[ "$1" ]] # get query from command line or clipboard
then
QUERY="$@"
else
QUERY="$(xsel)"
fi
QUERY=$(perl -MURI::Escape -e "print uri_escape('$QUERY');") # from: http://stackoverflow.com/questions/296536/urlencode-from-a-bash-script
$BROWSER "http://www.aa.tufs.ac.jp/~jwb/cgi-bin/wwwjdic.cgi?1MUJ${QUERY}"
exitYou'll want to tweak this script, again for speed, by setting the url in the last line but one to a mirror near you. (Mine's in Japan, and the server comes back almost instantaneously for me.
) There are links to half a dozen mirrors here. Use the part of the url up to the question mark, chop off the "1C" and replace it with the "1MUJ${QUERY}" in the script. You can also tweak the "1MUJ" bit if you want. See here.
Nearly there - now edit your openbox rc.xml to add a keyboard shortcut pointing to this script, or use xfce's keyboard settings. That should be it. ![]()
edit: See this post below for a Chinese version.
Last edited by johnraff (2011-06-13 16:49:49)
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?” "As it comes, Jeeves, as it comes..."