Google translate bookmarklet: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This code is a JavaScript bookmarklet that translates the current page into | This code is a JavaScript bookmarklet that translates the current page into Traditional Chinese using Google Translate. | ||
<pre> | <pre> | ||
javascript: location.href='https://translate.google.com/translate?sl=auto&tl=zh-TW&u= | javascript: location.href='https://translate.google.com/translate?sl=auto&tl=zh-TW&u='+location.href | ||
</pre> | </pre> | ||
== | == Explanation == | ||
1. `javascript:` - This part tells the browser that this is JavaScript code. | 1. `javascript:` - This part tells the browser that this is JavaScript code. | ||
| Line 11: | Line 11: | ||
2. `location.href=` - This will redirect the browser to a new URL. | 2. `location.href=` - This will redirect the browser to a new URL. | ||
3. `'https://translate.google.com/translate?sl=auto&tl= | 3. `<nowiki>'https://translate.google.com/translate?sl=auto&tl=zh-TW&u='</nowiki>` - This is the Google Translate URL, where: | ||
- `sl=auto` means automatically detect the source language | - `sl=auto` means automatically detect the source language | ||
- `tl=zh-TW` specifies the target language as | - `tl=zh-TW` specifies the target language as Traditional Chinese. Or replace with `tl=en` to specify the target language as English | ||
- ` | - `hl=` (optional) specifies the interface language of Google Translate itself. For example: | ||
- `hl=en` displays the Google Translate interface in English | |||
- `hl=zh-TW` displays the Google Translate interface in Traditional Chinese | |||
- If omitted, Google Translate will use your browser's default language | |||
- `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. | 4. `+location.href` - This appends the current page's URL to the Google Translate URL. | ||
| Line 22: | Line 26: | ||
# Create a new bookmark | # Create a new bookmark | ||
# 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 | # When browsing any webpage, click this bookmark to automatically translate the current page into Traditional Chinese using Google Translate | ||
Or use the generator: [https://translation-bookmarklet-generator.pages.dev/?lang=en Translation Bookmarklet Generator] | |||
[[Category: Translation]] | |||
[[Category: Tool]] | |||
[[Category: | [[Category: Revised with LLMs]] | ||
Latest revision as of 00:17, 26 December 2025
This code is a JavaScript bookmarklet that translates the current page into Traditional Chinese using Google Translate.
javascript: location.href='https://translate.google.com/translate?sl=auto&tl=zh-TW&u='+location.href
Explanation[edit]
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=zh-TW&u='` - This is the Google Translate URL, where:
- `sl=auto` means automatically detect the source language
- `tl=zh-TW` specifies the target language as Traditional Chinese. Or replace with `tl=en` to specify the target language as English
- `hl=` (optional) specifies the interface language of Google Translate itself. For example:
- `hl=en` displays the Google Translate interface in English
- `hl=zh-TW` displays the Google Translate interface in Traditional Chinese
- If omitted, Google Translate will use your browser's default language
- `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:[edit]
- Create a new 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 Traditional Chinese using Google Translate
Or use the generator: Translation Bookmarklet Generator