1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Quản trị mạng >

Hack 6. Translate Any Page with Yahoo!

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (15.01 MB, 888 trang )


Yahoo!'sLanguageToolspage

(http://tools.search.yahoo.com/language)hassomewaysto

helpyouworkwithotherlanguages.Amongthemisa

translationservicethatwilltranslateanyblockoftexttoa

differentlanguage.IcopiedtheRussiantextfromFigure1-10,

pasteditintothetextarealabeled"Translatethiswebtext,"

chose"FromRussiantoEnglish"fromthedrop-downlistof

languages,andclickedTranslate.Yahoo!respondedwiththis:

RadioDials.Thegalleryofthephotographsofancient,Iwillnot

be

afraidthisword,radios-scale.Theauthorofcollection,

photographer

PaulBausch,decidedthustopublishthepaternalcollectionof

radio

receivers.3x,dreamsabouttheirowntsifrozerkalkewiththe

macro-objectivebecomeincreasinglymoreimportunately.



Asyoucansee,theYahoo!translationtoolisn'tperfect,butit's

goodenoughtogiveasenseofwhatthepageistalkingabout.

Thetranslatedtextreferstothe"paternalcollection"ofphotos,

becausetheradiosIphotographedbelongedtomyfather.Istill

havenoideawhatthelastsentenceofthetranslationmeans,

butI'mclosertounderstandingnowthanwhenitwasin

Russian.



Ifyou'dliketolimitthesearchresultsthatYahoo!returnstoone

languageorahandfuloflanguages,youcansetyourpreferred

languagesinyoursearchpreferences.Bydefault,Yahoo!returnsthe

bestsearchresultsfromanylanguage.



AfasterwaytotranslateanypageyoufindinYahoo!Search

resultsisviathe"Translatethispage"linkincludedwithinthe

resultsfornon-Englishpages.Figure1-11highlightsthelinkin

thesearchresults.



Figure1-11.The"Translatethispage"linkin

Yahoo!Searchresults



Clickingthe"Translatethispage"linktakesyoutoatranslated

versionofthepage,ratherthanthepageinitsoriginal

language.

Ifyoufindyourselftranslatingpagesfrequently,therearesome

waystospeeduptheprocess.Youcantranslateanentireweb

pagebycopyingandpastingtheURLintothefieldlabeled

"Translatethiswebpage"ontheYahoo!LanguageToolspage,

choosingthelanguagefromthedrop-downmenu,andclicking

Translate.Yahoo!willdisplaythepagewithallofthetext

translated.



AnotherquickwaytotranslateentirepagesiswiththeYahoo!

Toolbar[Hack#12].Ifyou'vealreadyinstalledtheYahoo!

Toolbar,chooseAdd/EditButtons…fromtheToolbarSettings

buttontobringuptheCustomizeYahoo!Toolbarpage.Check

theboxnexttoTranslateCurrentPageunderSearch&

NavigationandthenclickFinished.Youshouldnowseeasmall

yellowfishbutton,liketheoneshowninFigure1-12,onyour

toolbar.



Figure1-12.TheTranslatebuttonontheYahoo!

Toolbar



Fromanywebpage,youcanclicktheTranslatebuttonand

Yahoo!willdisplayaversioninEnglish.Yahoo!willalso

automaticallydetectthesourcelanguage,soyoudon'tneedto

choosealanguagefromamenu.Thisisalsohandyifyoucan't

tellwhatlanguagethepageisin.Ifyoujustwanttotranslatea

blockoftextinsteadoftheentirepage,youcanclickthearrow

nexttothefishandchooseLanguageandTranslationTools

fromthemenu;you'llgototheYahoo!LanguageToolspage,

whereyoucanpastethetextyouwanttotranslateintothe

translationform.

IftheYahoo!Toolbarisn'tyourstyleandcopyingandpasting

intotheLanguageToolsisn'tfastenough,youcancreateyour

ownTranslatebuttonwithanunderstandingofYahoo!

TranslationURLsandaJavaScriptbookmarklet.



1.7.2.ATranslationBookmarklet



IfyouvisittheYahoo!LanguageToolspageandtranslatea

pagebyURL,you'llendupataYahoo!pagethatusesframes.

ThetopframeincludestheYahoo!Searchlogoandseveral

links:ViewOriginal,PrintTranslation,LanguageTools,andso

on.Thebottomframeistheoriginalwebpage,withallofthe

texttranslatedintoadifferentlanguage.Figure1-13shows

suchatranslatedpage,withtheO'ReillyHackspageinSpanish

inthebottomframe.



Figure1-13.TheHackssitetranslatedinto

Spanish



LookingattheURLintheaddressbar,you'llseethatyou'reata

Yahoo!pagewithsomeparameterspassedtoitinthe



querystring,includingtheURLofthepagetobetranslated.The

wholeURLlookslikethis:





http://tools.search.yahoo.com/language/translation/tran









php?tt=url&urltext=http%3A%2F%2Fhacks.oreilly.com%2F&



HerearethethreevariablespassedintheURL:



tt

Thetypeoftranslationtoperform



urltext

TheURLofthepagetotranslate



lp

Acodethatrepresentsthelanguagetotranslatefromand

to

KnowinghowtobuildYahoo!TranslateURLs,youcancreatea

bookmarklettofetchthecurrentpageURL,constructthe

properYahoo!TranslateURL,andopenitinanewwindow.



1.7.2.1.Thecode.

AswithotherYahoo!bookmarkletsthroughoutthisbook,this



JavaScriptisnotveryreadable,butiscondensedtoworkwithin

theconfinesofabrowserbookmark.Createanewbookmarkin

yourbrowserandthenbringitupforediting.Putthefollowing

codeintothelocationfieldofthebookmarkandbesuretogive

thebookmarkletadescriptivename,suchasYahoo!Translate:





javascript:d=document;void(window.open('http://tools.se









language/translation/translatedPage.php?tt=url&urltext=









href)+'&lp=xx_en','_blank','width=640,height=480,status









scrollbars=yes'))



Thevalueofthelpvariableinthiscodeisimportanttonote.

Thevaluexx_entellsYahoo!todeterminethelanguageofthe

pageyou'vesentittotranslate.Ofcourse,youcouldmakethis

alanguage-specificbookmarkletbyreplacingxx_enwithes_en

(SpanishtoEnglish),fr_de(FrenchtoGerman),oranyoneof

theothercodesforthetranslationsthatYahoo!supports.To

viewafulllistoftranslationcodes,simplyviewthesourceof

theLanguageToolspageandlookatthevalueattributeinthe

Xem Thêm
Tải bản đầy đủ (.pdf) (888 trang)

×