User:Endo999/GoogleTrans.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:Endo999/GoogleTrans. |
// does google toolbar like translation of words and selected text
// works on ie and firefox, epiphany, safari, chrome, and opera but still has bugs on
// Konqueror (in fact the code is disabled on Konqueror)
// selected text translation (up to 500 characters) only on IE, Firefox, and Epiphany, and chrome
// this has only been tested on the monobook skin
// default from and to language
// the languages must be the same as in google.language.Languages array.
// these are normally the international defaults but note:
// portuguese: pt-PT
// traditional chinese: zh-TW
// simplified chinese: zh-CN
//
// must be set in this routine for dictionarylookup.js
/*
var SCLanguageDefaultTo = 'fr';
var SCLanguageDefaultFrom='en';
*/
var SCLanguageDefaultTo = 'fr';
var SCLanguageDefaultFrom='en';
var SCShiftKeyNeeded = true;
// need to set document.domain here, each language should set this field here
document.domain = "en.wikipedia.org"
// default literals for system
// must be set in this routine for dictionarylookup.js
// the gadget manager can change these to the language he wishes
/*
var SCstrLanguage = "Language";
var SCstrSource = "Source";
var SCstrGoogle = "Google";
var SCstrCloseWindow = "Close window";
var SCstrSelectLanguage = "Select language (to)";
var SCstrWikipedialanguage = "Wikipedia language";
var SCstrDictionary = "Dictionary";
var SCstrWikipedia = "Wikipedia";
var SCstrPopupHelp = "GoogleTrans help?";
var SCstrTurnOffPopups = "Turn GoogleTrans off?";
var SCstrTurnOnPopups = "Turn GoogleTrans on?";
var SCstrTranslationPopups ="GoogleTrans";
var SCstrOff = " (off)";
var SCstrOn = " (on)";
var SCstrChangeOptions = "Change options for GoogleTrans";
var SCstrTranslatePage = "Google: translate page?";
var SCstrHelpUrl =
"http://en.wikipedia.org/w/index.php?title=User:Endo999/dictionarylookuphelp.html&ctype=text/html";
var SCstrSingleWord = "Translation of single words";
var SCstrSelectedText = "Translation of selected text (> 500 characters)";
var SCstrKonqueror = "This feature is not supported on Konqueror";
var SCstrTextTooLarge = "Text element too large to parse!";
var SCPopupBackgroundColor = "beige";
var SCstrShiftKeyNeeded = "Shift key down to bring up Popup?"
*/
var SCstrLanguage = "Language";
var SCstrSource = "Source";
var SCstrGoogle = "Google";
var SCstrCloseWindow = "Close window";
var SCstrSelectLanguage = "Select language (to)";
var SCstrWikipedialanguage = "Wikipedia language";
var SCstrDictionary = "Dictionary";
var SCstrWikipedia = "Wikipedia";
var SCstrPopupHelp = "GoogleTrans help?";
var SCstrTurnOffPopups = "Turn GoogleTrans off?";
var SCstrTurnOnPopups = "Turn GoogleTrans on?";
var SCstrTranslationPopups ="GoogleTrans";
var SCstrOff = " (off)";
var SCstrOn = " (on)";
var SCstrChangeOptions = "Change options for GoogleTrans";
var SCstrTranslatePage = "Google: translate page?";
var SCstrHelpUrl =
"http://en.wikipedia.org/w/index.php?title=User:Endo999/dictionarylookuphelp.html&ctype=text/html";
var SCstrSingleWord = "Translation of single words";
var SCstrSelectedText = "Translation of selected text (> 500 characters)";
var SCstrKonqueror = "This feature is not supported on Konqueror";
var SCstrTextTooLarge = "Text element too large to parse!";
var SCstrGuessLanguage = "Any language";
var SCstrShiftKeyNeeded = "Shift key down to bring up Popup? Turn Option "
var SCPopupBackgroundColor = "beige"; // you can set the popup background color here
appendCSS(
'.SCuserData { behavior:url(#default#userdata);} ' +
'#SCitem div small, #SCitem small,#SCitem div div small,#SCitem div div div small {font-size:65%;color:black}' +
'#SCitem div a:hover, #SCitem a:hover, #SCitem div div a:hover {text-decoration:underline;}' +
'.SCPopup {background-color:' + SCPopupBackgroundColor +';border: 1px solid blue;position:absolute;font-size:14pt;z-index:9999;' +'overflow:visible;line-height:normal;padding:.5em;display:block;}' +
'.SCxWindow {font-size:70%;color:black;' +
'position:absolute;right:.5em;}'+
'.SCyWindow{font-size:50%;color:black;position:absolute;right:.5em;'+
'bottom:.5em}' +
'.SCxTranslation {font-size:70%;color:black;' +
'position:absolute;left:.5em;top;.5em;}' +
'.SCxText {color:black;}'+
'.SCPopupIE {position:absolute;background-color: ' +
SCPopupBackgroundColor +
';border: 1px solid blue;font-size:14pt;z-index:9999; ' +
'overflow:visible;display:block;line-height:normal;padding:.5em;width:auto;}'
+
'.SChidestuff {display:none;}'
);
function SCGoogleLanguageLoaded() {
SCMakeGoogleLanguages();
}
function SCloadGoogleLanguage() {
google.load("language", "1", {"callback" : SCGoogleLanguageLoaded});
}
// this api key is not strictly necessary, but Google maintains they will email
// you if, for some reason, they withdraw the Google translation services
// the gadget manager is welcome to log onto code.google.com and get his own
// api key.
var SCGoogleAPIKey = "ABQIAAAAIL6lIdsFmMh3QB6iZZYqHBT5zsu4IrEqi6aTPGb6EkJ6C2zK0BQyWgLmv16JfxNy3RYUKg7GyR6XAg";
importScriptURI("http://www.google.com/jsapi?callback=SCloadGoogleLanguage&key=" +
SCGoogleAPIKey);
importScriptURI("http://en.wikipedia.org/w/index.php?title=User:Endo999/dictionarylookup1.js&action=raw&ctype=text/javascript");
addOnloadHook(
function () {
var span1 = document.createElement('DIV');
span1.setAttribute('id','SCitem');
var thebody = document.getElementsByTagName('BODY');
thebody[0].appendChild(span1);
var span2 = document.createElement('SPAN');
span2.setAttribute('id','SCPersistElement');
span2.setAttribute('class','SCuserData');
thebody[0].appendChild(span2);
}
);
var SCnewoptions;
function SCMakeGoogleLanguages()
{
var l;
var lcode;
var newoptions = "";
for (l in google.language.Languages)
{
lcode = google.language.Languages[l];
if(google.language.isTranslatable(lcode))
{
if(!l.match(/UNKNOWN/i))
newoptions +=
'<option value="' + lcode + '">' + l + '</option>'+"\n";
}
SCnewoptions = newoptions;
}
}