User talk:Endo999/GoogleTrans
Two code pages
[edit]I am wondering if there is a need to have two separate code pages, User_talk:Endo999/GoogleTrans.js and User:Endo999/dictionarylookup1.js, and if they could be merged into one. That would save one additional WP server request per page. Cacycle (talk) 23:18, 11 September 2009 (UTC)
Done, as you wished
Endo999 (talk) 00:08, 12 September 2009 (UTC)
Trailing interpunctuation
[edit]I have noticed that trailing interpunctuation (e.g. ".") is not stripped from single word lookups. Cacycle (talk) 00:05, 12 September 2009 (UTC)
Punctuation marks are now stripped out of single word lookups. they are kept for multiple word lookups.
Endo999 (talk) 00:53, 12 September 2009 (UTC)
Automatic language detection
[edit]You could set the target language to wgUserLanguage if wgUserLanguage is not identical to wgContentLanguage (i.e. a user has set the wiki user interface messages to different language than the wiki article content one. Cacycle (talk) 14:41, 12 September 2009 (UTC)
This can be done but it requires two AJAX calls to Google. Most of the time the language will be the default one so it is usually not necessary. It is a nice feature that I have implemented in other incarnations of the tool, but it definitely requires 2 calls to Google. Tell me if you still want it done.
Endo999 (talk) 16:59, 12 September 2009 (UTC)
- You can check wgUserLanguage and wgUserLanguage, they are set by the mediawiki software on every page. There are no Google calls involved for this feature suggestion, you will find them in every page source code in the head section. Cacycle (talk) 01:33, 13 September 2009 (UTC)
Thanks for telling me about those variables. I did not know about them. Your feature is now supported. It will only operate on the first use of the tool (or after cookies have been wiped). The translateTo language will be set to the wgUserLanguage when it is not the same as wgContentLanguage, unless
- 1) wgUserLanguage is not supported by Google, in this case 'fr' is the default code.
- 2) wgUserLanguage is a code, such as 'en-GB', which Google does not support but does support 'en'. In this case the last Google language that starts (for example) with 'en' is picked.
This controls the first use of the tool. If the client changes the language, then the cookie value will be used instead of wgUserLanguage.
It's a good feature because Germans now start out translating to German and they don't have to set this up when they begin use of the tool.
Endo999 (talk) 03:54, 13 September 2009 (UTC)
Name consistency / browser checks
[edit]Would you mind making the script's name consistent throughout the script, including the cookie names? Also, the popup UI texts miss spaces after punctuation (:, ->) In the long term it might also be a good idea to replace the browser name checks by testing for the availability of the respective properties or methods to make the script more robust and future-proof. Thanks, Cacycle (talk) 12:40, 18 September 2009 (UTC)
- Following changes made:
- 1) All references to 'TranslationPopups' changed to 'GoogleTrans' in code and in cookies
- 2) '->FRENCH' in popup now is '-> FRENCH'
- 3) 'Source:Google' in popup now is 'Source: Google'
- I will look at the Browser specific tests verses javascript tests for capabilities in the future as you have asked.
Endo999 (talk) 00:40, 19 September 2009 (UTC)
Feedback from Yug
[edit]Hello, my feeback :
- Since the SHIFT lock the opening of your pop up, it is no more need of the 2sec delay. Please reduce it to Zero to provide an instant translation. Time matter a lot.
- I still think your box have Chartjunk, please replace :
- -> by →
- French by fr: (iso code)
Those 3 changes are, in my opinion, simply better : doing the same work, faster, with less polluting pixel messages.
After what :
- I dont use it for Chinese->English : is your gadget available on zh wiki now ??? O.O !!!!
- Good to see that you get the gadget status !! Good work !
Thanks a lot ! Yug (talk) 09:32, 24 September 2009 (UTC)
- You might want to move this discussion to User_talk:Endo999/GoogleTrans. I agree an the delay and the arrow I but don't think it is a good idea to use language abbreviations. But please use lowercased language names (French instead of FRENCH) for the UI. There should also be an indication that clicking the language name opens up the preferences. Cacycle (talk) 13:30, 24 September 2009 (UTC)
I have put the following changes in my test version. These will be tested for a day and then if successful will be put in the production User:Endo999/GoogleTrans.js file on Saturday morning the 26 September 2009. They are looking good right now.
- popup happens within 1/4 a second from when shiftkey is put down(if shiftkey option off then it is still 1 second). This is basically instantaneous from the users perspective.
- languages now lowercase (ie.,) FRENCH now French
- → now replaces ->
- if the html element the mouse is over has
- in IE, more than 900 subelements, PROCESSING IS ABANDONED
- in any browser if there are more than 450 text subelements PROCESSING IS ABANDONED
- this prevents hangs in very large files (like 60,000 bytes of code), especially in IE. It is very unlikely that any actual Wikipedia article will ever be effected by this limit as it is meant for large files of code where there can be up to 12000 subelements in a html paragraph. Most Wikipedia articles are segmented into paragraphs whereas a code file is basically one paragraph.
Endo999 (talk) 22:36, 24 September 2009 (UTC)
- Regarding the sub-elements: you might be able to use the lightning-fast innerHTML method and strip html tags instead of traversing the DOM. to speed things up. Cacycle (talk) 12:49, 25 September 2009 (UTC)
The changes outlined above have been put in User:Endo999/GoogleTrans.js The popup will happen more quickly now, although in larger articles there is still a noticed delay (see Battle_of_Nicopolis for this. This is because the javascript has to parse several text elements in the html before it gets to the one the cursor is over. There isn't much that can be done about this.
Endo999 (talk) 23:22, 25 September 2009 (UTC)
How to Port to Other wikis
[edit]Porting is relatively simple:
- 1) See the code below from the near top of User:Endo999/GoogleTrans.js and make the following 3 changes (see comments in the code):
var SCLanguageTo='fr'; // 1) SET DEFAULT LANGUAGE TO TRANSLATE TO // (often 'en') var SCLanguageDefaultTo = SCLanguageTo; var SCLanguageDefaultFrom='en'; // 2) SET YOUR WIKI LANGUAGE HERE if(typeof wgUserLanguage != "undefined" && typeof wgContentLanguage!= "undefined") { if(wgUserLanguage != wgContentLanguage) SCLanguageDefaultTo = wgUserLanguage; } var SCShiftKeyNeeded = true; // 3) DECIDE IF YOU WANT SHIFT KEY HELD DOWN TO BRING UP // A POPUP (most will)
- 2) You can change the literals of the system to your native language, if you wish (although people seem to keep them as English), by changing the Javascript strings at the top of the file (just underneath the code above). These strings will have
the type of variable name
- var SCstrLITERALSTRING = "LITERALSTRNG";
- 3)User:Endo999/GoogleTrans.js is the only source file in the gadget. —Preceding undated comment added 05:42, 12 November 2009 (UTC).
Endo999 (talk) 05:47, 12 November 2009 (UTC)
Secure server
[edit]I noticed the gadget wasn't working when I was using the secure server. On that server the domain is secure.wikimedia.org, and thus "wiki.riteme.site" is not a valid value for document.domain. I made a small change that should fix this. —TheDJ (talk • contribs) 20:15, 24 November 2009 (UTC)
Chrome Extension Version
[edit]This tool is wonderful! Could you make this to be an extension for Google Chrome? It will be more fantastic if this tool can be used everywhere! --百楽兎 (talk) 12:51, 26 January 2010 (UTC)
IE Popup window disappears too quickly: fixed
[edit]Slight change to code to ensure that IE popup window does not disappear too quickly. Endo998 (talk) 22:11, 3 April 2010 (UTC)
Linux Shift Key Processing
[edit]I finally got a modern LINUX to test GoogleTrans on.
The evt.shiftKey variable is set differently on LINUX and Windows. On Windows it is set on the Keydown event, but on LINUX (firefox 3.5.4) it is set on the keyup event. Accordingly, some minor fixes to the keyup and keydown event handlers have been made to support both operating systems.
LINUX uses may have previously seen popups without the SHIFT key being pressed (after the first shiftkey pressing on a page). It should work as expected now.
On Firefox 1 no SHIFT key processing is done. If you use this browser then positioning the cursor, waiting 2 seconds will bring up the popup.
Endo999 (talk) 03:37, 10 September 2010 (UTC)
GoogleTrans and IE v9 beta
[edit]GoogleTrans version before the 29 Sept 2010 version do not work on IE v9 beta, except if you click on the compatibility mode button at the top of the window. GoogleTrans will work in IE v9 (pre 29 September 2010) if the webpage is being rendered in IE v8 mode. This is done by clicking the compatibility button which is just next to the refresh button.
GoogleTrans has been updated (as of Sept 29 2010) and now supports IE9 beta.
Other wikis who use GoogleTrans will need to update their gadget code with the current gadget on enwiki
See User:Endo999/GoogleTrans.js for the code.
Endo999 (talk) 00:25, 24 October 2010 (UTC)
Things to Note about IE9:
- 1) IE9 is more like Firefox 3 than IE8. The AttachEventListener call is available as well as the AttachEvent call.
- 2) setting fields in IE8 worked with:
- elem.style.left=16
- Now you need to do:
- elem.style.left=16px
- (This is like Firefox).
Endo999 (talk) 15:08, 29 September 2010 (UTC)
punctuation mark of Japanese
[edit]Hi Endo999. I am from Japanese Wikipedia. I am interested in this tool. I tested the code at jawp. The code works very well except one problem. A Problem is detection of Japanese punctuation mark "、" and "。". That does not work. So popup text extends over "、" and "。". If there are no wikilink, translated texts become very long.
- "、" is same as "," in English
- "。" is same as "." in English
If possible to fix this, I hope so. Thank you :-) --Was a bee (talk) 14:01, 22 September 2010 (UTC)
This is now fixed as of the October 19 2010 version of GoogleTrans. If SCLanguageDefaultFrom variable is set to "ja" or "zh-CN" or "zh-TW" then these puncutation marks will be observed. For Japanese/Chinese, with no space, it is not possible to know one word at a time so the entire phrase (up to next punctuation mark) is translated. Thanks to Was a bee for a significant amount of testing in order to test the new code changes. Endo999 (talk) 14:54, 27 October 2010 (UTC)
Overlap with CUA keys
[edit]Normally I would use either double-click to select a word (which doesn't work because Wikipedia jumps to the edit page if I do that) or extend the selection with shift+right arrow or shift+left arrow. I assume that GoogleTrans conflicts with this because it uses Shift.--greenrd (talk) 08:23, 30 September 2010 (UTC)
- I have changed GoogleTrans slightly so that you can now use the SHIFT ARROW keys and the SHIFT CLICK to extend the selection you wish translated on Firefox, Safari and Chrome. This DOES NOT work on IE however. The SHIFT ARROW sequence is not supported by IE and the SHIFT CLICK sequence does not work yet for GoogleTrans. You may notice that, now, the popup window is 5 pixels away from the cursor, so that cursor clicks do not do things to the popup. If after extending the selection via the SHIFT ARROW or SHIFT CLICK sequence the popup does not come up after you hit the SHIFT key again, move the cursor a few pixels and hit the SHIFT key again. This time the popup will come up. This is because, normally, clicking will disable a popup from coming up until the cursor is moved again. Endo999 (talk) 01:22, 10 December 2010 (UTC)
Zoom and translating selected text in IE
[edit]Until the October 19th 2010 version of Googletrans, if the zoom was not 100% then selected text was not correctly detected in IE, although FireFox was always okay.
This is now fixed as of the date above.
Due to new Wikimedia software on Tuesday 8th February 2011 no gadgets load
[edit]Due to new WIkimedia software loaded on Tuesday 8th Feb 2011, GoogleTrans (and no other gadgets) load now.
Endo999 is looking into this to see what has to happen to get the gadget up again.
Sorry for the inconvenience.
Endo999 14:19, 8 February 2011 (UTC)
The Wikimedia Software has been reverted back to the old version and gadgets should load okay now. If you have any problems remember to CTRL-PF5 on IE and SHIFT-PF5 on Firefox to reload all the wiki webfiles. Endo999 (talk) 18:54, 8 February 2011 (UTC)
Translate Next Sentence Command in Popup now if selection is being translated
[edit]As of 30 April 2011, the popup window, when a selection of more than one word is being translated, will have a translate next sentence? command.
If you click on this link the next sentence will be selected and translated. A new popup will occur with the translation of the next sentence.
This new command will make the selection translation much more powerful and quicker, as actually selecting the text with mouse commands is a long operation.
For single word translation this command will not appear.
If you select 2 words, for instance, and ask for the translation (position cursor within selection and hit SHIFT key), then the translate next sentence? link appears in the popup. By clicking it the rest of the sentence to the right will be selected and translated.
The algorithm to determine the next sentence is not foolproof. Basically the sentence has to be 10 characters long and the search will stop at the next period or question mark or semi-colon.
This command will work on IE, Firefox, Chrome, and Safari. Opera still does not support the javascript calls to determine if the cursor is within the selection.
On Firefox, Chrome, and Safari the translation popup will come up at the end of the current paragraph. Sometimes this paragraph can be long and this can mean the actual translation popup is below the screen. Just scroll down the webpage and you will see the popup. This is happening because Firefox et al does not support the getclientrects method on ranges, just elements. On IE the popup will be just below the selected text.
Endo999 (talk) 16:44, 30 April 2011 (UTC)
Google API V2 trial to get some stats from 7:00am Oct 7 2011 (UT+8)
[edit]I've put in a version of Googletrans that uses the V2 of the Google API. This is done in order to get some stats on usage of the gadget. This version will only be in for a few days or perhaps just one day. This version of the Gadget can be reverted to the previous stable version of the gadget if any problems arise.
GoogleTrans gadget is still due to be decommissioned on 1 December 2011 as the Google language API v1 (free use) is to be decommissioned then. If users of the GoogleTrans gadget wish for this gadget to continue, then please approach Google to allow an inkind donation of their language API v2 services. If this happens, then the gadget can continue to operate. I, personally, haven't been able to get past their receptionist with this request myself.
Endo999 (talk) 19:52, 6 October 2011 (UTC)
This test has now ended after 24 hours. The previous version of GoogleTrans is back in operation:
Some stats:
There were 26K requests to Google translation services over 24 hours.
90 percent of these were to ask for a list of translateable languages upon entering a new web page. It is obvious this list should be hardcoded into GoogleTrans since it does not change very often.
This left around 2.5K actual translation requests per day.
53% of requests came from the USA, 11% from Great Britain, 8% from Australia, 6% from Canada, and 4% from India. 46 different countries make at least one request.
At most 175 people were signed in, with GoogleTrans operating, at any one time. This amount varied over the 24 hours.
Endo999 (talk) 20:21, 7 October 2011 (UTC)
Quota Exceeded message in popup
[edit]Please reply if you are getting the following message in the GoogleTrans popup:
- Quota Exceeded. Please see http://code.google.com/apis/language/translate/overview.html
This looks related to the shutdown of Google language API V1 on 1 December 2011. I will wait until midnight UTC and see if the quote resets. If it doesn't I will put in my latest version of Google language API V2 (which lessens the number of requests) and see how that does.
Endo999 (talk) 22:14, 28 October 2011 (UTC)
I have placed a new version of GoogleTrans that uses the Google language API V2 in to get around the Quota exceeded problem.
60.229.250.221 (talk) 22:34, 28 October 2011 (UTC)
"Access Not Configured" Message
[edit]Google shutdown their V1 of the Google API on 1 december 2011. The googletrans gadget has been running on V2 of the gadget for a month now. However, when V1 of the API was shutdown, all GoogleTrans gadgets running v2 suddenly had "Access Not Configured" messages.
I'll look into this and get it fixed as soon as possible.
Endo999 (talk) 03:40, 2 December 2011 (UTC)
Protocol relative URLs
[edit]Hi,
Your script should use protocol relative URLs.
See this edit.
2 URLs have to be modified :
/* Currently :
var SCstrHelpUrl = "http://wiki.riteme.site/w/index.php?title=User:Endo999/dictionarylookuphelp.html&ctype=text/html";
*/
var SCstrHelpUrl = "//wiki.riteme.site/w/index.php?title=User:Endo999/dictionarylookuphelp.html&ctype=text/html";
/* ... */
/* Currently :
'onclick=\'javascript:window.open(\"http://' +
*/
'onclick=\'javascript:window.open(\"//' +
SCWikipedialanguage.substring(0,2) + '.wikipedia.org?go=Go&search=' +
encodeURIComponent(linktext) + '\")\'>' + linktext + '</a>';
--DavidL (talk) 13:49, 10 December 2011 (UTC)
Error messages in alert windows in Opera
[edit]When I try to select text with the shift key and the arrow keys or with the shift key and the mouse in Opera (11.61/Windows), I get an alert box saying "ob not found" and then a second one saying "unable to hide SC9". Very annoying. Turning off GoogleTrans from the googletrans tab menu didn't help either, I had to turn it off from My preferences/Gadgets to make the problem go away. By the way, if you need to show error messages, it would be nice to include the name of the script in them, so people can easily determine where the messages are coming from. --V111P (talk) 08:27, 6 March 2012 (UTC)
I've commented out those annoying "ob not found" and "unable to hide XXX" messages (which only happened under Opera). Sorry about that. Opera support was a late addition to GoogleTrans and it hasn't been used or tested as much as it should have been. Thanks for reporting the bug. Opera GoogleTrans still doesn't translate selected text as the other browsers do. Endo999 (talk) 21:57, 8 March 2012 (UTC)
- OK, thanks. I mostly use Firefox, but sometimes I use other browsers for various reasons. --V111P (talk) 01:37, 9 March 2012 (UTC)
Gujarati Language
[edit]Is this working for Gujarati Language?
I have made this see here
http://gu.wikipedia.org/wiki/સભ્ય:Harsh4101991/GoogleTrans.js
Can you find the problem ?-- Harsh Kothari (Talk/Contribution) 12:20, 19 December 2012 (UTC)
There is now a new version of GoogleTrans gadget at:
which does 13 new languages including the five Regional Indian languages which Google now supports.
You can use the new version by unclicking the production version of GoogleTrans in your profile and including the following line in your User:youriid/common.js file.
importScript("User:Endo999/common.js");
After a week or so of testing we will then update the production version. The new languages are:
Armenian Azerbaijani Basque Bengali Georgian Gujarati Kannada Lao Latin Esperanto Tamil Telugu Urdu
Endo999 (talk) 06:38, 20 December 2012 (UTC)
13 new languages supported by Google now supported by gadget: Indian Regionals plus others
[edit]Thirteen new languages are now supported that Google has recently supported. The new languages are:
- Armenian
- Azerbaijani
- Basque
- Bengali
- Georgian
- Gujarati
- Kannada
- Lao
- Latin
- Esperanto
- Tamil
- Telugu
- Urdu
6 Indian Regional languages are now supported, so I believe, these new additions will be well received by the Indian subcontinent readers of the enwiki.
Endo999 (talk) 20:04, 26 December 2012 (UTC)
Japanese GoogleTrans
[edit]Hi Endo999, when I was using the Japanese 'version' of the gadget, whenever I press SHIFT, it would not translate the text but instead ask to use Google Trans v2? I have no idea what that means, any suggestion on how to fix this? Many thanks! Kinkreet~♥moshi moshi♥~ 12:13, 8 March 2013 (UTC)
Hi Kinkreet,
Thanks for alerting me to this problem with the Japanese version of GoogleTrans. I've just updated it with the new version which will not show you that message. I've quickly tested and it seems to work okay. (Unfortunately, the "translate next sentence" doesn't seem to work well since it selects the whole page instead of the next sentence (because of the lack of periods in Japanese) Please tell me if there is any other changes you need in GoogleTrans gadget.
Endo999 (talk) 20:03, 8 March 2013 (UTC)
I've just fixed up "Translate Next Sentence" on the jawiki at:
Endo999/vector.js
Give it a try and tell me if it is useful to you
Endo999 (talk) 20:43, 8 March 2013 (UTC)
bosnian, cebuano, hmong, marathi, javanese and kymer languages added
[edit]The following 6 new Google languages have been added: bosnian, cebuano, hmong, marathi, javanese and kymer languages.
The changes are just changes to existing tables in the javascript code, so there shouldn't be any issues. If there are please contact me and I will unwind the changes.
Cebuano, hmong, marathi, and javanese are local languages and not national languages. So this is keeping in Jimbo Wales commitment to support regional languages over the next 10 years.
Endo999 (talk) 21:54, 1 July 2013 (UTC)
addition of hausa,igbo,maori,mongolian,nepali,punjabi,somali,yoruba, zulu languages.
[edit]The following languages have been added to the GoogleTrans gadget: hausa,igbo,maori,mongolian,nepali,punjabi,somali,yoruba, zulu
Five of these are African languages.
The gadget should function as before. Only 4 tables have been updated. No code changes.
Endo999 (talk) 06:16, 6 January 2014 (UTC)
Korean missing and pronunciation feature suggestion~
[edit]Hi~ The sample animation gif from your user page shows Korean being selected and translated. However, when I tried it, Korean wasn't even listed in the menu to select.
Also, is it possible to show pronunciation of non-Latin words in the popup, such as in Chinese pinyin, like Google Translate can on it's page? I think that'd be a great feature.
Thanks for taking time to make a great tool~:D Have a great day~!!! ^_^ ZeniffMartineau (talk) 22:02, 24 February 2014 (UTC)
1) I'll fix up the Korean this weekend. Thanks for noticing it. It must have slipped out when I was adding new Google languages. 2) Having the PinYin is a good idea. It's a matter of whether Google will return it in their API call. I'll find out this weekend.
Thanks for the encouragement. I hope GoogleTrans is useful for you.
Endo999 (talk) 05:44, 25 February 2014 (UTC)
Thanks for the quick reply! I just started using it and I look forward to testing it with Korean and any new features~:) ZeniffMartineau (talk) 05:13, 26 February 2014 (UTC)
Korean has been put back in as a language. Only tables were changed, no code changes. Please let me know if there are any problems.
Endo999 (talk) 00:46, 27 February 2014 (UTC)
It works~ Thank you very much! :D I'll let you know if anything else comes up~ ZeniffMartineau (talk) 00:28, 28 February 2014 (UTC)
GoogleTrans gadget not working on IE11 on Windows 8.1
[edit]I have just ascertained that the GoogleTrans gadget is not working on IE11 on Windows 8.1. I'll spend some time working on this and post about the bug soon. (It seems to be that, although Firefox selection objects are the only ones that work on ie11, IE11 doesn't support the containsNode() call on the selection object. Endo999 (talk) 21:12, 28 November 2014 (UTC)
I've put some preliminary fixes in that will allow ie11 to work for individual word lookups. I'll put this code into production in around a week's time, after some more testing on my test system. Translation of selected text will not work, for ie11, will not work for these ie11 fixes. That will take some more investigation, due to the nonexistence of the containsNode() call of the selection object in ie11. Endo999 (talk) 22:35, 28 November 2014 (UTC)
GoogleTrans gadget has been updated so that IE11 is now supported. Unfortunately, the selected text translation does not work at this time, but individual word translation does. Selected text translation will work on all other browsers except Opera. Please notify me if there is any unexpected behavior. Endo999 (talk) 19:51, 3 December 2014 (UTC)
The language change link on ie11 will now change the language correctly. The language change behavior is a little different from other browsers. Two subwindows will popup. You need to change the language on the second, click "X" at the top right of both the second and then the first popup windows to remove them. This new behavior effects language change behavior from the link in the popup on IE11 only. Endo999 (talk) 20:09, 5 December 2014 (UTC)
The double-click option
[edit]Is there a way to disable the double-click translating option? I would like to be able to select single words again when editing? -AngusWOOF (talk) 15:07, 7 February 2015 (UTC)
Okay, I'll put in an option to disable the feature in the next few days. Thanks for the feedback. Endo999 (talk) 20:49, 7 February 2015 (UTC)
I've put in a option to disable double click translation. It is in the test version of GoogleTrans available at:
If you put
- importScript("User:Endo999/testvector.js");
the above line in your User:XXX/vector.js file (and disable the gadget in preferences) you should run with the new version, which allows disabling of the option.
To disable the double click translation option you need to click on the MORE triangle (next to the Wikipedia search input box), click on GoogleTrans menu item, then click on the
"Turn Off Double Click Translation" link.
From then on, you should NOT have double click translation.
I will put this in the production version in a few days. I like to have a few days to see what the change is like in the test version.
Endo999 (talk) 22:07, 7 February 2015 (UTC)
Have you considered making this option opt-in instead opt-out? It is very non-standard behavior that is frankly rather annoying.
I also want to thank you for your contributions. I know that developers of publicly-accessible tools such as this typically see a distorted ratio of critiques to gratitude so I wanted to let you know that I (and surely many others) are grateful. GDW13 (talk) 03:27, 9 February 2015 (UTC)
Thanks for the feedback (and the compliment). I'll set the default behavior of GoogleTrans to NOT translate a sentence on the doubleclick. I'll undo the gadget to the last version (without double click translation) and then update with the new code in a couple of days
Endo999 (talk) 04:50, 9 February 2015 (UTC)
Minor changes for 18 April 2015
[edit]Minor changes have been put into the GoogleTrans gadget as of 18 April 2015
- 1) double click translation and next sentence translation will now stop on the Hindi end of sentence character as well as a full stop.
- 2) double click translation will not happen if GoogleTrans is turned off, even if Double Click translation is turned on
- 3) The translate to default language is now set to English, since other wikis are now starting to refer directly to the enwiki gadget code. This should not effect anyone who has set their language already or has a language set in their preferences.
If there are any untended consequences then please message me on this page.
Endo999 (talk) 21:43, 17 April 2015 (UTC)
Romanisation Trial turned off
[edit]Since Google has turn off its unofficial Romanisation (Pinyin) service then the GoogleTrans gadget will no longer try to print the Romanised or Pinyin version of the translated text. (This feature was only on in the hiwiki, srwiki, and the ukwiki).
I thought it was a good feature but it is no longer possible to provide.
Endo999 (talk) 21:53, 17 April 2015 (UTC)
MediaWiki 1.26 requires a change to MediaWiki:Gadgets-definition file to support GoogleTrans
[edit]wiki 1.26 requires a change to MediaWiki:Gadgets-definition to support gadgets. The enwiki version, which is working fine, has this entry in the above file for GoogleTrans:
- GoogleTrans[ResourceLoader]|GoogleTrans.js
(That bullet mark above is actually an asterick)
Endo999 (talk) 15:35, 8 August 2015 (UTC)
Article translations; Show multiple meanings?
[edit]Hi, Endo999, thanks for letting me know about the Integration of GoogleTrans gadget with Wikipedia Beta Translation system, I'll take a look at it now. We were just talking at the Bulgarian Wikipedia, how the Beta tool doesn't work for Bulgarian.
I was about to ask you something else, does the API allow you to get more than the one meaning of each word that GoogleTrans shows? In Google Translate you can see multiple meanings for each word.
--V111P (talk) 19:00, 5 September 2015 (UTC)
@V111P thanks for the quick reply. Let me know how your testing goes. The biggest problem I had was remembering to set the GoogleTrans gadget translate to language. I always had it as English so it translated from English to English. Unfortunately, I am unaware of how to get several meanings for the translation of a single word. I am aware that GoogleTranslate itself does this, but their API, which I must use, does not seem to provide this. If you can figure out how to do it, I would probably would this feature within the GoogleTrans gadget.
Thanks Again
Endo999 (talk) 19:08, 5 September 2015 (UTC)
- I think it's useful. It's still a lot of work to fix the machine translation, but it helps. I even started translating an article from Bulgarian to English, which otherwise would be a pain for me.
- You can detect the source and target language, using jQuery the former is
$('.cx-column--source').attr('lang')
and the latter$('.cx-column--translation').attr('lang')
. I'm just reading the lang attribute of the two div columns, there may be a more elegant way, but we may need to ask the Beta tool developers. --V111P (talk) 01:22, 7 September 2015 (UTC)
GoogleTrans gadget not always loading: starting 2/10/2015
[edit]Hi there,
For some reason the GoogleTrans gadget is loading intermittently. Sometimes it loads (check MORE menu item to see if it has). When it does load there is no javascript error message. When it doesn't load the following javascript error message can be seen:
- LOG: Exception in module-execute in module ext.cx.interlanguagelink:
- TypeError: Unable to get value of the property 'data': object is null or undefinedTypeError: Unable to get value of the property 'data': object is null or undefined
I assume this is a wiki thing since the gadget was last changed two weeks ago, and has run well since then. MediaWiki hasn't been updated, according to SignPost, either.
Endo999 (talk) 00:24, 2 October 2015 (UTC)
This error where GoogleTrans does not always load only happens when you have the beta Content Translation feature on. If you turn this feature off then GoogleTrans will always load.
A bug report on phabricator at [| 114462] has been issued for this problem.
Endo999 (talk) 15:34, 4 October 2015 (UTC)
This bug only seems to effect the enwiki. Other language wikis are okay.
Endo999 (talk) 15:45, 4 October 2015 (UTC)
This bug in loading GoogleTrans when Content Translations was active has now been fixed. T114462 is now closed.
Endo999 (talk) 21:12, 6 October 2015 (UTC)
MT transfer problem
[edit]- Goal of exercise: Implementing GoogleTrans for Ukrainian language.
- Actions taken: I've tried to follow the instruction:
- created the Сергей Олегович/common.js in ukrwiki
- incerted the line: mw.loader.load('//wiki.riteme.site/w/index.php?title=User:Endo999/GoogleTrans.js&action=raw&ctype=text/javascript'); (it is the only line in the page)
- tried the tric with holding CTRL+ALT on the selected text in the right column.
- Result The message: Ukrainian wiki doesn't support MT
- Question: What was wrong?
- Сергей Олегович (talk) 04:34, 15 October 2015 (UTC)
Try your query out now. I was limiting the CTRL-ALT html markup translation to just URLS with /ContentTranslation/ in them but your UKWIKI URL had a cyrillic item in the URL. I have changed GoogleTrans to limit CTRL-ALT translation to the Content Translation system in another way, so it should work in the ukwiki now. In fact I tried it out and it did work. The UKWIKI version of GoogleTrans already has the latest version of GoogleTrans so you shouldn't need a private version of the gadget. Thanks for trying out this feature and reporting the result. Endo999 (talk) 04:53, 15 October 2015 (UTC)
Internal Error message coming from Google
[edit]As of 4/12/2015 GoogleTrans is returning "Internal Error" on all accesses to Google. The web says this is a Google error and not a GoogleTrans gadget error. I have sent off a message to Google. Until this Internal Error clears up I have changed the version of the gadget to run off the Yandex Translation Engine, which is the Russian company.
Endo999 (talk) 17:30, 3 December 2015 (UTC)
As of 4/12/2015 I have reverted to another API key for Google so the gadget is running as usual now. It looks like the APIV2 key I was using suddenly stopped being valid. So we are running with Google translation engine again.
Endo999 (talk) 07:26, 4 December 2015 (UTC)
GoogleTrans gadget now has support for Yandex translation engine
[edit]As of 22/12/2015 GoogleTrans now can also use the Yandex translation engine for its translations. Otherwise, the user interface is exactly the same except that there is a combo box in the language-change popup where one can select the desired Google/Yandex translation engine. Default engine is Google. Please tell me if you inadvertantly have the Yandex translation engine now returning translations.
To set the translation engine, go to MORE at the top right of the screen, press on MORE, select GoogleTrans from the submenu. A Language change popup will appear. A combo box at the bottom of this popup will allow you to set your translation engine. You can also get into the Language Change popup by cursor hovering a word, Pressing SHIFT, which will bring up the translation word popup. At this time you can press the language link at the top left of the POPUP. This will bring up the Language Change Popup which has the Translation Engine Change combo box. Endo999 (talk) 23:58, 21 December 2015 (UTC)
I just checked the new version of Yandex to see if I can support V2 of its access methods. Unfortunately they don't seem to support Javascript access like they used to and they also require a new access key every 12 hours. This is good for security but I will not be able go support YANDEX translation in the foreseeable future. Endo999 (talk) 21:47, 21 February 2022 (UTC)
New Version of GoogleTrans gadget now in Production
[edit]The new version of GoogleTrans, which is now an object orientated Javascript object, is now in production. It will support IE9+, Edge, Firefox, and Chrome. Other browsers or early versions of the browsers should use the old version of GoogleTrans. Unclick the GoogleTrans gadget in preferences/gadgets, and put the following line in your common.js private file:
- mw.loader.load('//wiki.riteme.site/w/index.php?title=User:Endo999/OldGoogleTrans.js&action=raw&ctype=text/javascript');
Otherwise the new version of GoogleTrans should work exactly like the old one, except that now there is no option NOT to use the SHIFT key to bring up the popup.
As always, if I get enough bad feedback on the version we will revert back to the old version, and fix up the new one.
Endo999 (talk) 19:03, 21 December 2016 (UTC)
Re-translation
[edit]Hi, Endo999. Thank you for this easy working tool. I tried it today and liked how it works. I am from Azerbaijan, and regularly translating articles from English and Russian to Azerbaijani. I noticed, that Google Translate gives better results if I first translate from English to Russian and then to Azerbaijani. So I want to know, is it possible to add some scripts to your tool for this type of re-translation?--Wertuose (talk) 10:20, 17 March 2017 (UTC)
Hi Wertuose, thanks for your positive feedback on GoogleTrans. Unfortunately, it is not really possible to do this unless you translate first from English to Russian (publish the article in ruwiki) and then translate from ruwiki to azwiki. I guess that is not your intention.
You can try the Yandex translation engine, instead of the Google translation engine. See here [[1]] for help on this. GoogleTrans supports both translation engines. You select one in the language change dialog box.
Endo999 (talk) 10:32, 17 March 2017 (UTC)
Since you are an admin on azwiki, you could make the GoogleTrans gadget a gadget on the azwiki. Then everyone on the azwiki could do the translation feature as well as the normal translation popup stuff.
Endo999 (talk) 10:35, 17 March 2017 (UTC)
Hi Wetuouse, I just noticed that GoogleTrans is a gadget on the azwiki. Thanks for that. Endo999 (talk) 06:42, 23 January 2020 (UTC)
quản lý hiệu quả một quán nhậu
[edit]mình chuẩn bị mở một quán nhậu theo kiểu bình dân. mình đang lo lắng về cách quản lý. mong muốn đạt kết quả từ vị trí này,được thể hiện quanhững ý sau: doanh thu có,guồng máy nhân sự vận hành trơn tru và đồng bộ,đưa ra giấy tờ,hóa đơn hoặc giải trình như thế nào để người cấp cao hơn hiểu rõ một cách nhanh chóng va rõ ràng nhất>>> Quản lý nguồn vật tư(đồ ăn tươi sống,đã qua sơ chế hoặc tẩm ướp hay những sản phẩm thiết thực để đem về lợi nhuận cho công ty)>>>mong muốn có được cách thức quản lý khoa học va dễ hiểu để hạn chế đến mức thấp nhất cho việc thất thoát,hoặc không như mong đợi,hoặc ngoài thực tế(không nghĩ sẽ có.nhưng đã từng có va xảy ra)rát mong nhận được sự góp chấn thành va mô hình chung để giải bài toán thất thoát về mức thấp nhất có thể.†† — Preceding unsigned comment added by Pau18dn (talk • contribs) 16:36, 10 June 2017 (UTC)
Shift doesnt work
[edit]Why can't i use GoogleTrans when im trying to push the shift button? Nothing happens when im trying to push shift.Jullan3 (talk) 12:21, 3 June 2018 (UTC)
Google Traslate
[edit]Sometimes the translator in the translation tool generates loops that make the words do not translate well. Greetings. Ignacio2403 (talk) 23:46, 23 June 2018 (UTC)
New version of Content Traslation
[edit]Google Traslate does not work for me in the new trial version of google traslate, I ask you please update the code for the new version, because the gadget in that version does not work for me. Greetings. Ignacio2403 (talk) 22:26, 3 August 2018 (UTC)
- There hasn't been a new version of GoogleTrans for several months now, and even that version was just a code line change or two from the previous version. Please remember you need to turn on the gadget in the destination wiki, where you are translating to. That is, in the enwiki if you are translating from es to en, and in the eswiki if you are translating from en to es. You should also look at your javascript console in your browser and send me a listing of any errors there. Endo999 (talk) 19:39, 4 August 2018 (UTC)
Hi Ignacio2403, I can run GoogleTrans and Content Translation the Chrome browser, but it doesn't seem to work on the Edge browser. Suggest you try Chrome or at least Firefox. Endo999 (talk) 02:20, 15 August 2018 (UTC)
This gadget causes loads of js warnings
[edit]And this could be easily avoided to clear the console from the numerous messages this script yields. The part of the code that causes the warning (every second or so) is:
var ob = document.getElementById(this.SCcurrentLink);
The warning being:
Empty string passed to getElementById().
The non-emptiness of this.SCcurrentLink
could be checked.
Regards, Automatik (talk) 23:29, 26 November 2018 (UTC)
Thanks for telling me. I get onto it this weekend. Endo999 (talk) 04:46, 27 November 2018 (UTC)
I did the fix you asked for. Please tell me if it removes the warning messages for you. Endo999 (talk) 04:01, 29 November 2018 (UTC)
The two last languages (GoogleTrans)
[edit]Hello Endo999, I noticed a mistake at GoogleTrans gadget. The two last languages (Yoruba and Zulu) didn't appeared in the list of languages. I think so you forgot plus sign (+) at the end of the 982 and 983 line code, but you put comma instead of plus sign! Why? Am i true? Thanks! ⇒ AramTalk 11:52, 25 June 2019 (UTC)
Thanks for noticing that. I just fixed it up. Yoruba and Zulu seem to be working now. Please tell me if they aren't for you. You may have to reload the gadget (as in SHIFT RELOAD in the browser). Endo999 (talk) 15:39, 25 June 2019 (UTC)ئارام بکر
- Endo999 Great! Both of them are appeared now! ⇒ AramTalk 16:05, 25 June 2019 (UTC)
The GoogleTrans tab
[edit]The "googletrans (on)/(off)" tab takes up a lot of room. It would be much, much better if it was moved to the tools menu on the left sidebar. I'm using MonoBook. If you don't want to move it by default, is there some code I could use to either move it or at least change the text to something shorter? (I already shorten other tabs.) MANdARAX • XAЯAbИAM 23:02, 11 January 2020 (UTC)
I guess what you could do is establish a private version of the gadget in your <user>/common.js file and then change the relevant code yourself. I suggest changing the literals
GT.SCstrTurnOffPopups = "Turn GoogleTrans off?"; GT.SCstrTurnOnPopups = "Turn GoogleTrans on?"; GT.SCstrGoogleTrans ="GoogleTrans"; GT.SCstrOff = " (off)"; GT.SCstrOn = " (on)"; GT.SCstrChangeOptions = "Change options for GoogleTrans";
By shortening them you can possibly shorten the item under the MORE menu item. I don't actually think it takes much space myself, so I don't intend changing it for the gadget. However, if, in your private version of the gadget, you come up with some OKAY version of your change, I will think about including this into the gadget
You can copy the googletrans gadget file into your private user space. The gadget file is at: User:Endo999/GoogleTrans.js Endo999 (talk) 18:35, 12 January 2020 (UTC)
Don't forget to unsubscribe to the GoogleTrans gadget. Your private vesion will completely replace the official verison. Endo999 (talk) 18:58, 12 January 2020 (UTC)
- Thanks for the reply, but I've solved the issue without making my own copy of the gadget. If anyone else also wants to avoid the "googletrans (on)/(off)" clutter for a tab which you rarely if ever use, you can hide the tab entirely by adding
li#ca-TransPopsId{display:none;}
to your common.css.If you want access to the GoogleTrans options popup from the tools menu on the left sidebar, addmw.util.addPortletLink('p-tb',"javascript:GT.SCSettings()", "GoogleTrans", "", "GoogleTrans options");
to your common.js. You can customize it by replacing "GoogleTrans" with whatever text you want displayed in the toolbox, and "GoogleTrans options" with your desired mouseover tooltip. MANdARAX • XAЯAbИAM 22:53, 12 January 2020 (UTC) - Or, if you use the MoreMenu gadget and want the GoogleTrans link in your Page/Tools dropdown menu, add:
mw.hook('moremenu.ready').add(function (config) {
MoreMenu.addSubmenuLink(
'page', 'tools',
'GoogleTrans',
'javascript:GT.SCSettings()'
);
});
- to your common.js. MANdARAX • XAЯAbИAM 02:59, 13 January 2020 (UTC)
- Thanks for your code on this matter. Posting on this page will enable others who wish to use your CSS and javascript code to use the code. Endo999 (talk) 18:02, 14 January 2020 (UTC)
After enabled the widget, cursor would relocate unexpected after pressing "Shift" key when typing mid-line in New Discussion Tool replying to comment in Source Code mode
[edit]Please see https://phabricator.wikimedia.org/T302147 for description of how I encountered the problem, it seems like the widget have some incompatibility with the New Discussion Tool. C933103 (talk) 14:33, 11 March 2022 (UTC)
Interference with secondary sorting in tables
[edit]See Help:Sortable tables#Secondary key and multi-key sorting.
There can be a problem if the Google translation gadget is enabled in gadget preferences (in browsing section). It may seem like shift-click secondary sorting is not working because of the delay due to the translation popup for the name in the column head. It is not a problem if the sorting icons are in a separate row. See {{sort row}} (no longer exists). --Timeshifter (talk) 23:02, 11 March 2023 (UTC)
- Can you give me an example of this happening. The skin is new
- so this may be the reason. Endo999 (talk) 07:21, 12 March 2023 (UTC)
- See the 2 tables in Help:Sortable tables#Secondary key and multi-key sorting.
- I am using 2010 Vector in Firefox on a Windows 10 PC.
- It would be nice if one had to select the text, and then right click the selected text to get a popup window. In that popup window is a command to "translate with Google".
- That is how my translation addon in Firefox works.
- So no possibility of interference. Addon:
- Translate Now.
- Maybe you could make that the default in your gadget. Right-clicking selected text. Versus automatically popping up anytime any word is clicked.
- --Timeshifter (talk) 07:33, 12 March 2023 (UTC)
- )) Thanks for your example I tried it on Raspberry PI 4, Firefox and it worked quite well, although you are right about the delay. 1Select the table, 2) put the cursor within the blue selected text, 3) hit the Shift key for a second. You should get the translation by that. There is a Translation Content feature where the middle (right) column you select the table and then hit CTRL-SHIFT (maybe CTRL_ALT) and you get the table translated under the HTML. If this is what you want I don't think it was working in Edge 2 years ago but it does work in Chrome. Endo999 (talk) 07:57, 12 March 2023 (UTC)
- Endo999. I am not trying to get a translation. I am trying to stop the translation by your gadget. :)
- Right now your gadget tries to translate any word that is clicked. And one big place that people click individual words that aren't links on Wikipedia is in column headers in order to sort that column.
- So your gadget needs to stop doing that. People should have to take an extra step. I suggest selecting and right-clicking.
- As the Firefox translation add-on does. I can select a word, phrase, sentence, paragraph, or page, and after right-clicking that selection I get a menu with a translation command in it. I click that command, and the add-on will use Google translation to translate it.
- Your gadget could operate the same way. --Timeshifter (talk) 14:03, 12 March 2023 (UTC)
- As a workaround, consider clicking on the GoogleTrans(ON) item and turning GoogleTrans off for a while. This will stop the annoying feature you are mentioning. On the old skin this is under the MORE menu item, on the new skin it is to the right under ACTIONS.Endo999 (talk) 14:24, 12 March 2023 (UTC)
- Endo999. I assume you are talking about turning off the gadget in preferences:
- Special:Preferences#mw-prefsection-gadgets - in the "browsing" section.
- That is what I have done.
- --Timeshifter (talk) 15:03, 12 March 2023 (UTC)
- You can temporarily turn off the GoogleTrans behavior by going to the Properties sheet (under MORE in the old skin, by the Actions on the right on the new skin.). click on the clink on the properties sheet to turn off google trans until you wish to turn it on again. Endo999 (talk) 00:59, 13 March 2023 (UTC)
- As a workaround, consider clicking on the GoogleTrans(ON) item and turning GoogleTrans off for a while. This will stop the annoying feature you are mentioning. On the old skin this is under the MORE menu item, on the new skin it is to the right under ACTIONS.Endo999 (talk) 14:24, 12 March 2023 (UTC)
- )) Thanks for your example I tried it on Raspberry PI 4, Firefox and it worked quite well, although you are right about the delay. 1Select the table, 2) put the cursor within the blue selected text, 3) hit the Shift key for a second. You should get the translation by that. There is a Translation Content feature where the middle (right) column you select the table and then hit CTRL-SHIFT (maybe CTRL_ALT) and you get the table translated under the HTML. If this is what you want I don't think it was working in Edge 2 years ago but it does work in Chrome. Endo999 (talk) 07:57, 12 March 2023 (UTC)
Endo999. I do not see properties sheet under More. I am on a desktop PC using Firefox. In Windows 10 Pro. --Timeshifter (talk) 02:34, 13 March 2023 (UTC)
- Look under "TOOLS" menu item at the right for this page to see GoogleTrans(ON) property sheet. They are changing the new skin so often.
- Endo999 (talk) 20:13, 13 March 2023 (UTC)
- Endo999. I can see it now under "More" at the top of the page. I wasn't paying attention to the fact that I had been turning it on and off in preferences. Sorry about that. Not functioning at my best when sleepy. :)
- --Timeshifter (talk) 20:45, 13 March 2023 (UTC)
- Any fix for this yet? waddie96 ★ (talk) 10:38, 2 October 2024 (UTC)
Waddie96 and Endo999. Nowadays I use this addon:
- Simple Translate (Firefox): Also available for: Edge. And Chrome.
Maybe some of its code can be used and adapted for the gadget translator. --Timeshifter (talk) 14:31, 2 October 2024 (UTC)
- Thanks! waddie96 ★ (talk) 16:04, 2 October 2024 (UTC)
- You're welcome. --Timeshifter (talk) 16:21, 2 October 2024 (UTC)
Support Kurdish (Sorani)
[edit]Hi, please add "Kurdish (Sorani)" ckb
right below "Kurdish" ku
. And change "Kurdish" ku
label to "Kurdish (Kurmanji)". The labels are the same as Google Translate labels. Thanks! ⇒ AramTalk 11:21, 27 May 2024 (UTC)
- Thanks for alerting me to this. Please give me a week to get the change into production. Endo999 (talk) 00:34, 29 May 2024 (UTC)
- @Endo999: Thanks for the reply. Please take your time. By the way, Kurdish (Sorani) was added alongside 23 more languages and 21 of them had a Wikipedia project. One day after adding those languages IIRC, phab:T308248 was created to support them. Thanks! ⇒ AramTalk 03:57, 29 May 2024 (UTC)
- Well I added the extra language (soroni is in arabic script and the other is in latin script). Please tell me if this is working for you. Endo999 (talk) 14:08, 29 May 2024 (UTC)
- @Endo999 It's working for me. Well done and thank you! ⇒ AramTalk 14:44, 29 May 2024 (UTC)
- Thanks for the feedback, and thank you for the help in maintaining the GoogleTrans gadget. Endo999 (talk) 21:29, 29 May 2024 (UTC)
- @Endo999 It's working for me. Well done and thank you! ⇒ AramTalk 14:44, 29 May 2024 (UTC)
- Well I added the extra language (soroni is in arabic script and the other is in latin script). Please tell me if this is working for you. Endo999 (talk) 14:08, 29 May 2024 (UTC)
- @Endo999: Thanks for the reply. Please take your time. By the way, Kurdish (Sorani) was added alongside 23 more languages and 21 of them had a Wikipedia project. One day after adding those languages IIRC, phab:T308248 was created to support them. Thanks! ⇒ AramTalk 03:57, 29 May 2024 (UTC)