I wanted a way to quickly translate any web page in any language to English with a single click of a button. I use Firefox as my main browser, but I'd assume you can do this in IE and other browsers also.
- Right-click on the Firefox Bookmarks Pane and choose "New bookmark".
- In the Name field, fill in: Translate.
- In the Location field fill in:
javascript:window.location='http://www.google.com/translate_c?u='+window.location
Now when ever you're on a page that isn't in English, just click on the "Translate" bookmark and the page will be translated for you.
How it works is that in the Location field you can place JavaScript using the URL pseudo JavaScript protocol. A URL has about 5 main parts:
- http:// - This is the Protocol
- www.example.com - The domain
- /path/ - The path to the page on the domain
- ?query=abc&query2=xyz - The query (an associative list of parameters and values)
- #bookmark - The bookmark (a link to a part of a page)
The JavaScript we execute is:
window.location='http://www.google.com/translate_c?u='+window.locationThe JavaScript executes in the scope of the current document, so window.location will refer to the current URL. (or window.location.href if you want to be specific, window.location probably has a toString() method that returns this.href).
So when clicked the bookmark executes the JavaScript code that instructs the window to go to the Google Translate page and appends teh current URL as the parameter value for u, which is the URL to translate.
I did a search and found this Extension for Firefox also: https://addons.mozilla.org/en-US/firefox/addon/918. It allows you to translate the selected text inside a web page with Google Translator. We could also do the same with our bookmark method, but since there is an extension for it, lets just leave it at that. Enjoy.
1 comment:
Hello! I am a blog fan from the Philippines. I just happen to discover your site. It is interesting. I find it worth visiting.
Post a Comment