SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-05-24 17:49:26

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

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

edit 121005 Dillo 3 is now available in the Wheezy repositories. smile 
Unfortunately the dillo 2 deb files I linked to above are no longer available, and dillo 3 is not in the Squeeze repos. If you're using Statler and need a dillo deb file, I've put my own copy (ssl enabled) here but remember this is a personal copy of someone else's PPA file so there are no guarantees whatsoever about its contents.

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=NO

Have 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}"

exit

You'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. smile ) 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. smile

edit: See this post below for a Chinese version.

Last edited by johnraff (2012-10-05 05:29:07)


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

Be excellent to each other!

#2 2011-05-25 11:44:14

kiiroitori
#! CrunchBanger
From: Tokyo, Japan
Registered: 2010-12-07
Posts: 205

Re: Fast Japanese or Chinese dictionary

johnraff, do you know about the rikaichan extension in firefox/chrome? It seems like your script does roughly the same thing in Dillo, am I right? There is also the perapera kun extension, based on rikaichan, I don't remember the differences between these but they are great.


I love #! more than my own kids. I told them and they sympathized.

Offline

#3 2011-05-25 16:03:47

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: Fast Japanese or Chinese dictionary

I've heard of such extensions, but there are two differences here:
1) You're not limited to looking up stuff that appears in your browser window. This script will take anything you've selected with the cursor - from an email, text file, Excel spreadsheet...
2) You don't need to have Firefox running, and even if it is running, I think this way will be faster. Try it smile


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

#4 2011-05-25 22:43:04

kiiroitori
#! CrunchBanger
From: Tokyo, Japan
Registered: 2010-12-07
Posts: 205

Re: Fast Japanese or Chinese dictionary

Oh I see, I didn't understand those key points! Thank you for very much for this!


I love #! more than my own kids. I told them and they sympathized.

Offline

#5 2011-05-27 12:35:14

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,212
Website

Re: Fast Japanese or Chinese dictionary

johnraff,

an excellent idea. Thank you for sharing this! I will try to change it to Chinese, and if you don't mind, post it here. Basically there are only 2 parts (dillo's rc and the dictionary server) which need to be altered a bit.

Greetings!


Start Distrohopping here! -> Break your own... cool  VSIDO  cool LinuxCNC  kiss Frugalware <- It's all just a kernel.

Offline

#6 2011-05-27 16:47:43

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: Fast Japanese or Chinese dictionary

@machinebacon please post a Chinese version! I'll change the thread title accordingly.
Any other variations equally welcome. smile


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

#7 2011-06-09 04:46:47

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: Fast Japanese or Chinese dictionary

This is not good news for foreigners living in Japan. That was a nice fast server, but it looks as if it will be closing down. I hope Jim Breen manages to find a substitute mirror in Japan. sad


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

#8 2011-06-13 16:24:08

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,212
Website

Re: Fast Japanese or Chinese dictionary

Hi John, 大家好

So this is the Chinese version, it was actually much easier to configure than the Japanese version, because the Chinese EDICTs accept the xsel content directly in the URL. I have added 3 servers, 2 of them are disabled and can be easily changed by removing the #.

So here's dillorc

# These two fonts will work best, pick one of your choice
# 这两种字体好用,清挑选
font_sans_serif="AR Pl UMing CN"
font_serif="AR Pl UMing CN"
#font_sans_serif="AR Pl Ukai CN"
#font_serif="AR Pl UKai CN"

# 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=NO
# Disable images if you want to save bandwidth and gain speed :)
load_images=NO

quickdict.sh

#!/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
# all three websites work bidirectional 
# 这些网页都是汉英英汉 随便看一下
#$BROWSER "http://dict.hjenglish.com/app/w/${QUERY}"
#$BROWSER "http://old.www.iciba.com/search?s=${QUERY}"
$BROWSER "http://dict.youdao.com/search?q=${QUERY}"
exit

BTW: John, I found an english-japanese/japanese-english dictionary based in China, you can have a try:

# JP -> ENG
$BROWSER "http://cn.bab.la/%E8%AF%8D%E5%85%B8/%E6%97%A5%E8%AF%AD-%E8%8B%B1%E8%AF%AD/${QUERY}"
# ENG -> JP
$BROWSER "http://cn.bab.la/%E8%AF%8D%E5%85%B8/%E8%8B%B1%E8%AF%AD-%E6%97%A5%E8%AF%AD/${QUERY}"

Last edited by machinebacon (2011-06-13 17:54:28)


Start Distrohopping here! -> Break your own... cool  VSIDO  cool LinuxCNC  kiss Frugalware <- It's all just a kernel.

Offline

#9 2011-06-13 16:45:51

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

Re: Fast Japanese or Chinese dictionary

Thank you machinebacon!
I'll change the thread title to "Fast Japanese or Chinese dictionary", at least until someone contributes a Korean or other version.
I'll also have a look at that Japanese dictionary server you found. smile


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo