Skip to content

Commit c5000b8

Browse files
committed
Rewrite of translation bookmarklet
1 parent 5225cff commit c5000b8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

javascripts/Google Translate.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
var selection;
3+
if (window.getSelection) {
4+
selection = window.getSelection().toString();
5+
} else if (document.selection && document.selection.type != "Control") {
6+
selection = document.selection.createRange().text;
7+
}
8+
if (selection === undefined) {
9+
location.href = 'https://translate.google.com/translate?langpair=auto%7Cauto&u=' + encodeURIComponent(location.href);
10+
} else {
11+
location.href = 'https://translate.google.com/translate?langpair=auto%7Cauto&ie=' + encodeURIComponent(document.characterSet) + '&text=' + encodeURIComponent(selection);
12+
}

javascripts/To English.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)