Webの翻訳

IE8をインストールしたら図のような機能がついていた。


使って見るとこれがなかなかいい感じ。

何がいいって翻訳もそれっぽいし、Googleの翻訳やエキサイト翻訳のように
ちょっと多い情報量になると翻訳できないという制限がない。


普段、Sleipnirを使っているのですが、翻訳したい時だけIE8を起動して
使うなんてめんどくさい。
初めてSleipnirの自作スクリプトを作って見よう!
(めんどくさいってかなりの動機だなーって思った)

LiveSearchTranslator.js

var obj, document, id, ndoc, nid, str;

obj = new ActiveXObject("Sleipnir.API");
id = obj.GetDocumentID(obj.ActiveIndex);
document = obj.GetDocumentObject(id);

if (document == null) {
	obj.MessageBox("Document を作成できません");
} else {
	str ="<html>\n";
	str+="<body>\n";
	str+="<script type=\"text/javascript\">\n";
	str+="document.location.href=\"http://www.microsofttranslator.com/BV.aspx?ref=Internal&a=" + encodeURI(document.URL) + "\";\n";
	str+="</script>\n";
	str+="</body>\n";
	
	nid = obj.NewWindow("about:blank",true);
	ndoc = obj.GetDocumentObject(nid);
	ndoc.write(str);

	ndoc = null;
	document = null;
}
obj.beep();
obj = null;

これを
Sleipnirのインストールパス\plugins\scriptsに置くと
アクションとして認識される。(Sleipnirの再起動は必要)


あとはSleipnirのオプション設定でマウスジェスチャーとかに割り当てる。
私の場合、図のような感じ。

実際に使って見た方はご感想をお待ちしております!!