Google translate bookmarklet: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
(Created page with "This code is a JavaScript bookmarklet that translates the current page into Tradition Chinese using Google Translate. <pre> javascript: location.href='https://translate.google.com/translate?sl=auto&tl=zh-TW&u=%27+location.href </pre> == Explantion == 1. `javascript:` - This part tells the browser that this is JavaScript code. 2. `location.href=` - This will redirect the browser to a new URL. 3. `'https://translate.google.com/translate?sl=auto&tl=en&u='` - This is t...")
 
mNo edit summary
Line 23: Line 23:
# Paste this code into the URL field of the bookmark
# Paste this code into the URL field of the bookmark
# When browsing any webpage, click this bookmark to automatically translate the current page into English using Google Translate
# When browsing any webpage, click this bookmark to automatically translate the current page into English using Google Translate
Note: Revised with the LLMs


[[Category: Translation]] [[Category: Tool]]
[[Category: Translation]] [[Category: Tool]]

Revision as of 14:01, 11 October 2024

This code is a JavaScript bookmarklet that translates the current page into Tradition Chinese using Google Translate.

javascript: location.href='https://translate.google.com/translate?sl=auto&tl=zh-TW&u=%27+location.href

Explantion

1. `javascript:` - This part tells the browser that this is JavaScript code.

2. `location.href=` - This will redirect the browser to a new URL.

3. `'https://translate.google.com/translate?sl=auto&tl=en&u='` - This is the Google Translate URL, where:

  - `sl=auto` means automatically detect the source language
  - `tl=zh-TW` specifies the target language as Tradition Chinese. Or replace with `tl=en` to specifies the target language as English
  - `&u=` will be followed by the URL of the page to be translated

4. `+location.href` - This appends the current page's URL to the Google Translate URL.

To use this bookmarklet:

  1. Create a new bookmark
  2. Paste this code into the URL field of the bookmark
  3. When browsing any webpage, click this bookmark to automatically translate the current page into English using Google Translate


Note: Revised with the LLMs