MediaWiki talk:Gadget-GoogleTranslate.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search


Bug fix[edit]

{{editprotected|technical=yes}} Please update the last line to:

// Allow jQuery to initialize first, in-case it was imported using importScript / importScriptURI
if( typeof jQuery == "undefined" ){
	addOnloadHook(GTrans.install);
}else{
	$j(document).ready(GTrans.install);
};


I use importScript() to import jQuery, because i don't have access to the server-files as admin, and due to that this gadget doesn't initialize and even gives this javascript error in console of Firebug:

$j is not defined
$j(document).ready(GTrans.install);MediaWiki talk:Gadget-GoogleTranslate.js (Line 50)

Maybe you can even skip the check and make it:

// Allow jQuery to initialize first, in-case it was imported using importScript / importScriptURI
addOnloadHook(GTrans.install);

--TriMoon (talk) 11:35, 3 February 2011 (UTC)[reply]

Someone needs to determine if this code works with ResourceLoader. – Adrignola talk 19:30, 26 August 2011 (UTC)[reply]
Adrignola: At MediaWiki:Gadget-HotCat.js the following code is used:
if (window.jQuery) {
    window.jQuery(document).ready(run);
  } else {
    addOnloadHook (run);
  }
So replacing "run" with "GTrans.install" could work but I have no idea about resource loader. According to mw:ResourceLoader/JavaScript Deprecations addOnloadHook is deprecated.
TriMoon: But why you can't access JQuery? Where can I read more about this limitation? I am sorry for my curiosity. -- RE rillke questions? 18:06, 14 September 2011 (UTC)[reply]
I think the $j "shortcut" might be initialized too late. $ will be fine.--DieBuche (talk) 12:24, 13 October 2011 (UTC)[reply]

Error handling[edit]

Currently the gadget fails with an error if the source text and the target language (by default, the interface language) are the same language. It would be nice if the script could check for this collision and ask the user what target language to give to the Google API. Rd232 (talk) 16:06, 11 November 2011 (UTC)[reply]

Also, the whole Shift business is a bit fiddly and unreliable. How about a tab link to send the entire page to Google Translate (in a new tab), in addition to the existing Shift approach? Rd232 (talk) 16:17, 11 November 2011 (UTC)[reply]
Also, I tried overriding the target language as the script suggests (User:Rd232/vector.js), and it's not working for me. Rd232 (talk) 16:19, 11 November 2011 (UTC)[reply]

End of the road[edit]

It appears that on 1 December 2011 Google will close down the (free) Google Translate API, and the gadget will therefore stop working. [1]. A potential replacement gadget could use the approach of {{Google translate}} to send the entire page to Google (not via the API). Rd232 (talk) 19:59, 13 November 2011 (UTC)[reply]