K-Meleon
KMeleonWiki > Resources > MacroLibrary > MacroLibrary2 > Translate
Submitted by: jsnj
-English- -EspaƱol-
Notes:
Modeled after the behavior of the Firefox extension, this script translates webpages and selected text to your chosen language
using the AltaVista Babel Fish and Google translation engines. You should also update to the latest Umlauts macro.
# ----TRANSLATION MACROS---- # $trlang= "kmeleon.general.translation"; $tralta= "http://babelfish.altavista.com/babelfish/tr"; $trgoog= "http://216.239.37.104/translate_c?u="; Translate{ &TrDef; &Selected; $add==""?$add=$url:""; $add==$url ? &TrURL:&TrSel; setclipboard($old); } TrDef{ $tr=getpref(STRING,$trlang); $tr!=""?"":$tr=en; } TrEng{ $xul=$tralta.$trpref."?lp=".$lang.$tr.$trsuf.$add; } TrSel{ $trpref=""; $trsuf="&urltext="; $word=$add; &Umlauts; $add=$word; &TrEng; &XUL; } TrURL{ $trpref=url_pagecontent; $trsuf="&url="; &TrEng; $tr==en ? open($trgoog.$url):open($xul); } Dutch{ $lang=nl_; &Translate; } English{ $lang=en_; &Translate; } French{ $lang=fr_; &Translate; } German{ $lang=de_; &Translate; } Greek{ $lang=el_; &Translate; } Italian{ $lang=it_; &Translate; } Japanese{ $lang=ja_; &Translate; } Korean{ $lang=ko_; &Translate; } Portuguese{ $lang=pt_; &Translate; } Russian{ $lang=ru_; &Translate; } Spanish{ $lang=es_; &Translate; } Chinese-Simple{ $lang=zh_; &Translate; } Chinese-Traditional{ $lang=zt_; &Translate; } Setlanguage{ &TrDef; alert("nl = Dutch\nen = English\nfr = French\nde = German\nel = Greek\nit = Italian\nja = Japanese\nko = Korean\npt = Portuguese\nru = Russian\nes = Spanish\nzh = Chinese-Simple\nzt = Chinese-Traditional\n\n\nEnter your two-letter language code into the following prompt.", "Select Your Language",INFO); $tr=prompt("Enter your language code:","Select Your Language",$tr); $tr==""?"": setpref(STRING,$trlang,$tr); }
Anywhere above &Tools
Translate From{ macros(Dutch) macros(English) macros(French) macros(German) macros(Greek) macros(Italian) macros(Japanese) macros(Korean) macros(Portuguese) macros(Russian) macros(Spanish) macros(Chinese-Simple) macros(Chinese-Traditional) - macros(Setlanguage, Select Your Language...) }
and within &Tools
&Tools{ %ifplugin macros :Web Search :Page Search :Keyword Autosearch - :Translate From :Mail and News
and within Selected Text
Selected Text{ :Translate From - macros(URL, Go to URL) macros(EmailText, Send by Mail)