Diqqət! 4 aprel 2024-cü il tarixdən saytın yeni versiyası sheki.org domenində fəaliyyət göstərir. Bu köhnə versiyadır və yenilənməsi məhdudlaşdırılıb. Lakin 6 yanvar 2025-ci il tarixədək bu vəziyyətdə internetdə qalacaqdır...

"MediaWiki:Gadget-GoogleTrans.js" səhifəsinin versiyaları arasındakı fərqlər

Şəki Ensiklopediyası səhifəsi
Jump to navigation Jump to search
(Səhifəni '{{shortcut|WP:GOOT}} I have created a Gadget (see code) that will marry the Google translation JavaScript API with Wikipedia.<br> == Inst...' ilə yarat)
 
(Səhifənin məzmunu '// _________________________________________________________________________________________ // |...' yazısı ilə dəyişdirildi)
Teq: Replaced
 
Sətir 1: Sətir 1:
{{shortcut|WP:GOOT}}
+
//  _________________________________________________________________________________________
 +
// |                                                                                         |
 +
// |                    === WARNING: GLOBAL GADGET FILE ===                                  |
 +
// |                  Changes to this page affect many users.                                |
 +
// | Please discuss changes on the talk page or on [[Wikipedia_talk:Gadget]] before editing. |
 +
// |_________________________________________________________________________________________|
 +
//
 +
// Translation tool that uses the "Google Translate" API.
 +
// Opens a translation popup for selected text or word under the cursor when pushing the shift button.
  
I have created a Gadget (see [[User:Endo999/GoogleTrans.js|code]]) that will marry the Google translation JavaScript API with Wikipedia.<br>
+
// imports [[User:Endo999/GoogleTrans.js]]
 
 
== Install ==
 
 
You can get the '''GoogleTrans''' Gadget by going to '''my preferences''' while logged in, clicking on the Gadget tab in your profile and then selecting '''Google Trans'''.
 
 
 
Then, you need to restart your browser (clear the cache) to get it working. Shift+F5 also works for Firefox and CTRL+F5 works for Internet Explorer.
 
 
{{copyedit-section}}
 
 
 
Once you have selected the '''Google Trans''' Gadget:
 
 
 
== Features ==
 
 
 
<div>
 
[[File:TranslationGadget.gif|thumb]]
 
<small>Remember to hit SHIFT key to bring up Popup (even now if you are on the eswiki or the ptwiki).</small>
 
</div> 
 
 
 
1) '''Like the Google toolbar''': whenever you place the cursor over a word and press the '''SHIFT''' key, a popup will happen with the foreign language translation of the word.  When you move the cursor away from the word, the popup window will disappear.  You can do this for selected text also ( up to 500 characters) in most browsers except
 
Safari v3- (Safari v4 is okay) and Opera. 
 
 
 
'''Note:''' You can turn off the need to hold down the '''SHIFT''' key by clicking on the '''googletrans''' tab at the top of the page and clicking on the link that turns this feature off. 
 
If you do this you need to hold the cursor over the word for 1 to 2 seconds.  If you have the
 
'''SHIFT''' key option on (the default), the popup happens within 1/4 of a second after the '''SHIFT''' key is pressed. 
 
 
 
'''Note:''' Some older browsers like Firefox v1 and Safari v3 never have the '''SHIFT''' key
 
option enabled.  In the case of these two browsers simply positioning the cursor over a word
 
will cause a popup to happen.
 
 
 
2) '''Over 50 languages:''' as many languages as Google does.  The Change Translation Languages popup window has a To language.  Click on the '''->French''' (ie) at the top of the Popup window
 
to change the language being translated to.
 
 
 
3) '''Works with:''' IE, Firefox, Epiphany, Safari, Opera, and Chrome.  This feature is turned off
 
for Konqueror at the moment because 2005 Konquerer does not run the javascript well.  Perhaps later
 
versions of Konqueror do, but I have not tested them. 
 
 
 
4) '''And:''' when a cursor is placed within selected text, all the selected text is translated (this for IE, Firefox, Chrome, Safari v4, and Epiphany).  Safari v3 and Opera don't support this option.  (Only 500 characters will be translated). 
 
 
 
'''Note:''' Some languages, like Hindi, seem to translate less than 500 characters at a time.  If you select a paragraph to translate but the Google translation never appears, go back into the text and select a lesser amount of characters.  You will most likely get this lesser amount translated. 
 
 
 
5) '''Within the popup''' are some links:
 
:a) A '''->FRENCH''', as an example.  This means translation is happening from any language to French.<br />  If you click on this link you may change the translation language. 
 
 
 
:'''Note:''' The beginning default translation  language comes from your Wikipedia profile, if Google supports this language.  For most people there is, thus, no need to select a translation to language. 
 
:b) a '''Source: Google''' link which takes you to the Google translation web page.  If you click on this link the entire page is translated by Google. 
 
:c) An '''X''' link, just in case moving the cursor away from the popup does not get rid of the popup.
 
 
 
 
 
6) '''To stay up:''' move the cursor into the popup, or outside the frame of the document (like onto the nondocument part of the browser) the popup window will stay up.
 
 
 
7) There is a '''googletrans (on/off)''' tab.  (on/off)  tells whether the '''GoogleTrans''' feature is on or off.  Click on the tab to get the '''GoogleTrans''' popup window, which will allow you to toggle the feature on or off. 
 
 
 
 
 
;Others
 
 
 
The page goes beyond the Google translation feature of their toolbar: over 50 languages are supported (translations between them and not just from English), and translation of selected text paragraphs (up to 500 characters) happens for IE, Firefox, Chrome, Safari v4 and Epiphany.
 
 
 
The translation software at Google is very powerful and I thought I would marry the premier language site on the web with it.  The Javascript for determining the word under the cursor in a web page is mine.
 
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 02:59, 11 October 2008 (UTC)
 
 
 
Wikipedia's mission, making all knowledge available to all people for free, is a noble goal, and overcoming language barriers to achieve this is also a noble, if subsiduary, part of Wikipedia's mission.
 
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 00:42, 12 April 2015 (UTC)
 
 
 
==Selected Text Translation==
 
[[File:GoogleTransSelectedTextTranslation.png]]
 
 
 
Translation of small amounts of selected text is possible.  Select less than 500 characters of text, <b>put the cursor within the selected text (preferably right on a word within the selected text)</b>, and hit the SHIFT key.  At this point you will see a popup (like the picture shown) with the translated text.  If you wish to have the next sentence translated, simply click on the "Translate Next Sentence?" link at the bottom left of the popup.  There is a minor bug in the code.  Sometimes you have to position the cursor within the selected text <b>on a word within the selected text that is not the last word in the selected text</b>.  In other words, position the cursor on a word within the selected text that is not the last word in it.
 
=="Select?" link in popup will now select translated text==
 
As of 14 March 2015, the GoogleTrans gadget on the enwiki will have a "Select?" link in the bottom left of the popup. If you click on
 
this link then the translated text in the popup will be selected.  You can then type ctrl-c to copy this translated text to the clipboard.
 
 
 
Some example:
 
 
 
[[File:GoogleTransGadgetSelectPopup1.png|thumb|GoogleTrans gadget popup with translated text selected (after "Select?" link has been hit)]]
 
 
 
[[File:GoogleTransGadgetSelectPopup2.png|thumb|GoogleTrans gadget popup with translated text selected (after "Select?" link has been hit)]]
 
 
 
Lately, it has become clear that many users of the GoogleTrans gadget are wiki to wiki article translators.  This option has been put in to help them translate articles more quickly. 
 
 
 
If there are any bugs or unintended features you do not like, then please post me on this articles TALK page.
 
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 21:48, 13 March 2015 (UTC)
 
 
 
==Double Click on word will translate it and rest of sentence==
 
As of 14 February 2015 the new version of the GoogleTrans gadget on the enwiki will do sentence translation when you double click on the first word in a sentence (that is not in a link).
 
 
 
<b>This is an OPT-IN feature.  You have to set the "Turn Double Click Translation On" link in the language change popup box in order for this to happen.</b>
 
 
 
To turn the feature on, if you wish, click on the "More" item next to the Search box, click on the "GoogleTrans" menu item and click "Turn On Double Click Translation".
 
 
 
To turn the feature off, if you wish, click on the "More" item next to the Search box, click on the "GoogleTrans" menu item and click "Turn Off Double Click Translation".
 
 
 
The feature is normally OFF.
 
 
 
If the gadget is doing double click translation and you have not set it to do this, please contact me on my Talk page.
 
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 22:44, 13 February 2015 (UTC)
 
 
 
==A Click On the Google Link In The Popup Will Translate The Entire Page==
 
 
 
In the bottom right of the translated text popup you will see a '''Google''' link.  If you click on this link then the entire webpage is sent to translate.google.com and translated.  This way you don't have to translate sentence by sentence (via selected text translation).
 
== How to Port to Other wikis ==
 
 
 
One way to port GoogleTrans to your wiki, solely by using the enwiki gadget file, is putting the single line into your gadget file in your wiki:
 
 
 
<pre>
 
 
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/GoogleTrans.js&action=raw&ctype=text/javascript');
 
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/GoogleTrans.js&action=raw&ctype=text/javascript');
</pre>
 
 
This is now the preferred way to run GoogleTrans, since there is no need to update the Gadget code anymore, as the enwiki version will always be up to date.  Because of changes to media wiki code there is need for small changes to GoogleTrans from time to time.
 
 
If your wiki doesn't have the GoogleTrans gadget you can create your own personal version by placing the above line in your private <b>common.js</b> (or skin) file.  Then the GoogleTrans gadget will load whenever you sign into Wikipedia.  That is your <b>User:<AccountName>/common.js</b> filename now.
 
 
You can also install it in all Wikimedia wikis by placing the code above in your [[:m:Special:Mypage/global.js|global.js]] file on Meta. If you don't want it to work on wikis with a specific language, just place <code>if (mw.config.get('wgContentLanguage') != 'en')</code> before it, where ''en'' is the language code.
 
 
You can copy the gadget file into your wiki and do it that way.  The following tells you how to do this:
 
 
Porting is relatively simple:
 
 
:1) See the code below from the near top of [[User:Endo999/GoogleTrans.js]] and make the following 2 changes (see comments in the code):
 
<pre>
 
GT.SCLanguageTo='en';  // put default language to be translated to here
 
GT.SCalttranslateFrom="";
 
GT.SCLanguageDefaultTo = GT.SCLanguageTo;
 
GT.SCLanguageDefaultFrom='en';  // put default language to be translate to here
 
</pre>
 
 
: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 GT.SCstrLITERALSTRING = "LITERALSTRNG";
 
 
:3)[[User:Endo999/GoogleTrans.js]] is the only source file in the gadget.
 
 
==GoogleTrans gadget is on the Following Wikipedias==
 
 
Google translates the following languages as of  2 July 2013(<b>astericks indicate GoogleTrans exists on the wiki</b>).
 
 
<pre>Language Code   Language Code
 
ACHINESE      * ace (is working but Google does not support Achinese).
 
AFRIKAANS af   ITALIAN it
 
ALBANIAN sq   JAPANESE ja</pre>
 
 
                                JAVANESE        jv
 
                                KAZAKH *        kk
 
ARABIC  * ar (gadget had 3000 users on arwiki, but doesn't work now, as gadget code needs updating)  
 
                                KOREAN * ko
 
(GoogleTrans needs to be updated on arwiki to support ie11)
 
BANJAR *      bjn  (this language is close enough to either indonesian or sundanese to be translatable, gadget code needs to be updated)
 
BELARUSIAN * be  (gadget code needs updating)  
 
                                LATVIAN lv
 
(gadget not working on be.wikipedia.org, needs to be upgraded)
 
BOSNIAN        bs              KHMER          km
 
BUGINESE  *    bug(gadget is on wikipedia but google does not support Buginese yet)
 
BULGARIAN bg   LITHUANIAN lt
 
CATALAN ca       MACEDONIAN * mk
 
(gadget is not working on mk.wikipedia, needs to be upgraded)
 
 
CEBUANO        ceb
 
CHINESE zh       MALAY * ms
 
CHINESE_SIMPLIFIED zh-CN MALTESE mt
 
 
                                MARATHI        mr
 
                                NEPALI  *      ne
 
CHINESE_TRADITIONAL zh-TW NORWEGIAN * no (gadget needs to be upgraded to support IE11)
 
                                PASHTO  *      ps 
 
CROATIAN * hr   PERSIAN * fa
 
CZECH cs           POLISH pl
 
DANISH da           PORTUGUESE * pt
 
DUTCH * nl           PORTUGUESE_PORTUGAL pt-PT
 
ENGLISH * en   ROMANIAN ro
 
ESTONIAN et   RUSSIAN ru
 
FARSI *        fa
 
FILIPINO tl   SERBIAN * sr
 
:                              Sinhalese *    si (gadget file needs to point to correct code for gadget)
 
:                              SIMPLE *        simple                             
 
FINNISH fi         SLOVAK sk
 
FRENCH fr           SLOVENIAN sl
 
(Googletrans gadget is on fr.wikiversity.org, fr.wiktionary.org, fr.wikibooks.org)
 
                                SOMALI *        so (gadget needs to be upgraded)
 
GALICIAN gl   SPANISH * es
 
GERMAN de           SWAHILI sw
 
GREEK el           SWEDISH sv
 
HAITIAN_CREOLE ht   TAGALOG tl
 
HEBREW iw           THAI th
 
HINDI * hi           TURKISH tr
 
 
HMONG  hmn
 
HUNGARIAN hu   UKRAINIAN * uk
 
                                URDU      *    UR
 
ICELANDIC is   VIETNAMESE * vi
 
INDONESIAN * id   WELSH cy
 
IRISH ga           YIDDISH yi
 
 
==Some Stats on GoogleTrans Gadget Usage==
 
 
As of 10 February 2015 there are around 23,700 users who load the gadget.  Of these around 1 in 9 are active users.  Around 2500 different users load the gadget over a 2 week period.  Between 400 and 800 translation requests are made each day, more on the weekdays than on the weekends and holidays.  Most people only use single word translation as the average translation request is around 8 characters long. 
 
 
Extensive work has been done on selected text translation but most people don't use it.
 
 
Recently during a 2 day trial of double-click-translates-current-sentence the useage amount went up from 800 to 2500, however, most people were actually double clicking to select the current word instead of wanting to have the sentence translated.  From this short 2 day period I conclude that most users of the gadget on the enwiki are translators.  They are translating an article over from the enwiki to other wikis.  These people basically know English but every once in a while they want to have a word translated.  Most users don't actually use GoogleTrans gadget to learn English.  However, the gadget has found a niche among the many wiki to wiki translators.
 
 
The gadget is on around 15 wikis now, including the simple wikipedia, the wiki designed for people to learn English.
 
 
I almost always get positive feedback when users message me on the Gadget.  I'd like to thank all the people who gave me feedback or helped me with the gadget.
 
 
== Open Source Project ==
 
'''GoogleTrans''' is now an open source project hosted at
 
 
"http://code.google.com/p/googletrans"
 
 
The code there is the code running at Wikipedia with some extras:
 
 
:1) on IE text within input fields and textareas can be translated and replaced
 
:2) a '''Wikipedia?''' link within the popup will bring up a list of Wikipedia links (can get a wikipedia article up on a term within a webpage without selecting it).
 
:3) just include 1 12k javascript file and a link within your website to get the dictionary/wikipedia lookup effect.  A second 80k javascript file is dynamically loaded if the GoogleTrans option is clicked on.
 
:4) two Perl scripts are included that
 
::a) read a webpage
 
::b) change every link within that webpage to be a link to itself (with the original link URL as a data parameter)
 
::c) inject the javascript files within the website that is presented to the user, so that every URL called by the Perl script suddenly has the cursor hover dictionarylookup effect.
 
::d) one of the Perl scripts is an introductory page that tells the user how to do cursor lookup and how to get other websites to have this effect.
 
 
The open source code allows anyone to effect the cursor hover dictionary/wikipedia lookup on any website.  The Perl scripts can get 99 percent of the websites out there and massage the website so the effect happens on it.  This should be good on online newspapers (any body can do Wikipedia lookups easily) and language schools (students can read other language websites and get help on words or phrases they don't understand).
 
 
== How to GoogleTrans NonWikipedia Websites ==
 
 
A website exists that allows any website to have the Cursor Hover Translation effect happen on an image of it.  It is at:
 
 
"http://www.securecottage.com/cgi-bin/reference.cgi"
 
 
This webpage educates the user about the cursor hover Translation effect, and then
 
 
:1) on any link within the website will produce Cursor Hover Translation on that website
 
::(Google is one such link)
 
:2) on any URL typed into an input field the Cursor Hover Translation effect is done.  Type the URL in and hit '''Go To URL'''.
 
:3) On ''any link within the retreived website'' Cursor Hover Translation behavior will also happen.
 
 
When a link or URL is retreived by the Perl script involved:
 
 
:1) the Perl script changes all links within the website to point to itself (with the original URL as a data member)
 
:2) injects dictionarylookup20a.js and dictionarylookup20.js javascript files into the web image given to the user.
 
 
'''Small Changes:''' In IE text within input fields and textareas also has the Cursor Hover Translation effect.  Within these two types of fields a "Replace Text" link happens in the popup so that the translation text can replace the original text.
 
 
Effectively, the user can surf the web with the cusor hover dictionary lookup behavior on 99 percent of all websites. 
 
 
This website is the demonstration website of the Open Source GoogleTrans website mentioned above.
 
 
== Japanese/Chinese processing ==
 
If the variable SCLanguageDefaultFrom is set to "ja" or
 
"zh-CN" or "zh-TW", (if Japanese or Chinese), then the following happens:
 
 
:1) the phrase up to the first punctuation mark is translated as there is no space to differentiate words.  If spaces are present they are observed though.
 
 
Two provisos on Firefox selection processing for ja|zh (Japanese/Chinese) languages with GoogleTrans are:
 
 
::1) If part of a phrase is selected and the cursor is over another part of the phrase (not selected), the selection is translated, not the phrase.
 
::2) If the cursor is over a space (for ja|zh languages) then the selected text will not be detected.  If the cursor is over a character or punctuation mark (except space) within the selection, then it will be detected.
 
 
Due to the strange detection scheme I have implemented for Firefox, I am unable to fix these two above problems.  They shouldn't be too hard to live with.
 
 
Some [[:ja:Wikipedia:ツール/グーグル・トランス|Japanese documentation]].
 
 
==Translate Next Sentence Command now in Popup ==
 
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.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 16:43, 30 April 2011 (UTC)
 
 
==Google has deprecated their Language API==
 
As of late May, Google has '''deprecated''' their language API v1, and will discontinue its use on December 1 2011.  GoogleTrans uses this API.
 
So after November 2011 the gadget will have to use another company's API if it is to remain in operation.  The GoogleTrans gadget will
 
remain unaffected until that time.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 14:55, 4 June 2011 (UTC)
 
 
GoogleTrans has been converted over to V2 of the Google language API and will continue to
 
run after December 1st 2011, when v1 of the API ends.
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 07:56, 4 November 2011 (UTC)
 
 
==The gadget WikiBhasha on hiwiki looks good, for translators==
 
 
For translators, the HIWIKI gadget, [http://www.wikibhasha.org/ WikiBhasha], looks like it is worth looking at.  The HIWIKI is the Hindi Wiki.  There is a video to explain its use. (No longer supported. [https://phabricator.wikimedia.org/T29139])
 
 
==IE11 now supported==
 
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.  IE11 supports selections like firefox does, but does not support the range.containsNode() call that the gadget needs to understand if the cursor is within the selected text.
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 19:53, 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.
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 20:08, 5 December 2014 (UTC)
 
 
==New Languages Supported==
 
 
10 new languages are supported by the GoogleTrans gadget now.  This keeps the gadget up to date with Google translation services right now.
 
 
If you want to know which languages are supported, then consult [[Google_Translate]] for a list of currently supported languages.
 
 
The newly supported languages by the GoogleTrans gadget are:
 
 
Chichewa,
 
Kazakh,
 
Malagasy,
 
Malayalam,
 
Myanmar (Burmese),
 
Sesotho,
 
Sinhala,
 
Sundanese,
 
Tajik,
 
Uzbek
 
 
As well, code for Romanisation (showing pronounciation of word or words in the Roman alphabet, aka, Pinyin for Chinese) has been integrated into the main version of the gadget, although it has existed for 6 months in the ukwiki and the hiwiki.  For the enwiki (and for most wikis) this code is turned off and will not run.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 20:43, 26 December 2014 (UTC)
 
 
==MediaWiki v1.26 requires a change to the MediaWiki:Gadgets-definition file==
 
 
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)
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 15:31, 8 August 2015 (UTC)
 
 
==GoogleTrans Integration With Content Translation System Doesn't Seem To Work In Edge Browser==
 
After some tests on different browsers it seems that the CTRL-ALT translation of the paragraph under the
 
html markup <b> DOES NOT</b> work on the Edge Browser, although it does seem to work on IE11, Firefox, and Chrome.
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 02:47, 17 August 2018 (UTC)
 
 
For conspiracy theorists, it makes sense that EDGE does not support the GoogleTrans GADGET, because:
 
 
:gaDGEt
 
:&nbsp;&nbsp;eDGE
 
 
Since the terms match, it would be a CROSSWORD CRIME if the edge browser supported the GoogleTrans gadget.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 01:57, 18 August 2018 (UTC)
 
 
==Integration With Wikipedia Beta Translation System: Now In Production Version Of Gadget==
 
 
The GoogleTrans gadget has been made to work with the new Wikipedia article translation system. This code is in the production version of the gadget now, but you may need to have a private version of the gadget if your destination wiki does not have GoogleTrans.  (put this following line into your private <b>User:MyUserName/common.js</b> file):
 
 
:mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/GoogleTrans.js&action=raw&ctype=text/javascript');
 
 
To use the new article translation feature:
 
 
:1) Ensure that an up to date version of GoogleTrans (see above for line to include into your private User space common.js, ie., <b>User:MyUserName/common.js</b> file) is running in the destination wiki for your article translation.  That is, if you are translating an article from French to English ensure that your enwiki common.js file has the line shown above in it. (You will also have to deselect the GoogleTrans gadget in that wiki, if it is loaded).
 
:2) Go into the Wikipedia beta translation system and select the article to be translated (say from French to English)
 
:3) Now that you are in the article itself, and the wiki does not offer automatic translation (as the frwiki does not), click on a paragraph from left column.  It will reappear in the second column now. So, in my case, the French in the left column will now appear as French in the middle column.
 
:4) Select the whole paragraph (in the second column). 
 
:5) With the paragraph selected hold down the <b>CTRL</b> and <b>ALT</b> keys at the same time. <b>The second column will now have  the text translated (from French to English in this case) but the HTML markup will be kept!</b> It will be translated to the language of the wiki you are on, not what language you have set GoogleTrans to translate individual words to (in the popups).
 
:6) Repeat this process for all the paragraphs in the article.
 
 
The end effect is just like that automatic language translation feature of the beta Wikipedia translation system (your article is machine translated paragraph by paragraph), but the main advantage of the GoogleTrans gadget feature is that all of the language translation pairs provided by Google Translate are available, not just the few language pairs that the Open Source Apertium translation system (which Wikipedia uses) supports!
 
 
The HTML markup is kept, and this aids translation.
 
 
The CTRL-ALT translate under markup effect will only happen on the Beta Wikipedia translation feature.  The Url has to have 'ContentTranslation' within it in order for the new feature to operate.
 
 
You can select parts of paragraphs.  You cannot select more than one paragraph at a time.
 
 
You can select HTML tables.  They will be translated and the HTML table will be kept.
 
 
View the following images to get a feed for how the translation feature works:
 
 
<table>
 
<tr><td>Get the paragraph in the Translation system to the second column</td></tr>
 
<tr><td>[[File:GoogleTransTranslationHelp1.png|thumb|Help For GoogleTrans gadget translation feature]]</td></tr>
 
<tr><td>Select the paragraph, and hold down <b>CTRL-ALT</b> keys at the same time.  The translation will be to the language of the wiki you are on, ie., the destination wiki.
 
</td></tr>
 
<tr><td>[[File:GoogleTransTranslationHelp2.png|thumb|Help For GoogleTrans gadget translation feature]]</td></tr>
 
<tr><td>The paragraph will be translated, in the second column, and the HTML markup will be kept.
 
</td></tr>
 
<tr><td>[[File:GoogleTransTranslationHelp3.png|thumb|Help For GoogleTrans gadget translation feature]]</td></tr>
 
</table>
 
In my case, I have intermediate French skills and so I am interested in translating French articles to English.  Apertium (and therefore Wikipedia) does not offer a French-English translation pair, but Google translate does.  So the GoogleTrans gadget is more general, for automatic translation, than Wikipedia is.  See [[http://wiki.apertium.org/wiki/List_of_language_pairs]] for a list of currently supported Apertium translation pairs.  Spanish is the only major language supported with English at the the moment.
 
 
After some feedback from the user community, apparently there are times when the translation back from Google lags a bit.  Most times the text you are changing, via translation, will change within a second of you pressing CTRL-ALT key combination down.  However, there are times when Google lags on this and I have seen up to 10 to 15 seconds of lag before the translation comes back.  So press the CTRL-ALT key combination down firmly (making sure you have text selected) and then wait.  The translation will eventually come back, but sometimes not right away.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 21:24, 19 September 2015 (UTC)
 
 
===You Can Translate HTML Tables In The Content Translation System Using GoogleTrans===
 
 
One of the better features of GoogleTrans under the Content Translation system is that you can translate HTML tables quickly and easily, just like you do a normal paragraph.  The tables often have simple but repetitive text to be translated and oftentimes the Google Translation engine does a very good job on them.  You can actually save yourself the manual translation of 100s of cells of a table this way, particularly if the cell has a city name or a date, as they often do in Track And Field articles.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 19:50, 11 July 2017 (UTC)
 
 
==YandexTrans: A version of the gadget that calls the Yandex Translation Engine==
 
 
This version of GoogleTrans, available for private use at:
 
 
:mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/YandexTrans.js&action=raw&ctype=text/javascript');
 
 
Put the above line in your private <b>common.js</b> file.
 
 
uses the Yandex machine translation engine, which is supposed to be better than the Google translation for Cyrillic languages. 
 
 
The gadget is almost exactly the same, including the Content Translation system, as the current GoogleTrans gadget.
 
 
People translating to and from Cyrillic languages may be interested in giving this version a try.
 
 
The Yandex Translation API key is at the top of the code, so you can
 
 
:1) make a private version of the Yandex gadget by placing it in your <b>common.js</b> file.
 
:2) get your own private Yandex Translation API key and replace my key with yours at the top of the code.
 
 
From that time on you will have your own translation quota instead of sharing the quota of all the users of YandexTrans.
 
 
You can sign up for your Yandex API key at:
 
 
:[[https://tech.yandex.com/translate/?ncrnd=3158|Yandex Translation API key]]
 
 
David Saroyan had an idea about a Yandex/Google combo box for translation engine switches so I have put the change into
 
 
[[https://en.wikipedia.org/wiki/User:Endo999/YandexTrans.js  YandexTrans.js]]
 
 
It should default to the Yandex engine. Tell me if it doesn't for you.  If you go to the menu item MORE/YANDEXTRANS then the resulting popup will have a combo box for changing the translation engine.
 
 
I have found the translation from french to english to be much better under Google than Yandex and I presume translating from English to a Cyrillic language will be better under Yandex.
 
 
Remember that you need to have the translation engine set in the destination wiki.  You can bring this up by hovering the cursor over a word, pressing the SHIFT key and then selecting the language link at the top left of the popup.  This will bring up the language change box which has the translation engine combo box now.
 
 
If this works out okay, it will probably go into the main gadget in several weeks time.  For right now the default translation engine for YandexTrans.js is Yandex.
 
 
==Notes On Translating Articles Using GoogleTrans==
 
The Content Translation system, in which the GoogleTrans gadget will now translate and replace text instead of offering a popup as before, is quite good actually. 
 
 
A beginner at wiki to wiki translation, I have been able, using the GoogleTrans gadget and the Content Translation system, to translate over 200 articles from the French Wikipedia to the English Wikipeda, over 150 of them were French lady athletic biops, most of the corpus I would say.
 
 
It's very clear after 200 translations that Machine Translation is very helpful in wiki to wiki translation because it means you can be an intermediate user of the source language, and you only need to be fluent in the destination language.  For language pairs like English-French, the Google Translation is good enough to use around 50 percent of the time (for simple articles like French Forts).  Another 50 percent of the time, you can figure out what is a better translation by looking at the source language and working it out, with the help of the GoogleTrans gadget popup feature.  You do need to know what is a good sentence in your destination language, and what is a bad one, because you always need to fix up the bad Google translation grammar for every single sentence. 
 
 
Thus Machine Translation not only speeds up translation (for good machine language pairs), but it allows a wider group of people to do the translation because they only need to be fluent in the destination language.
 
 
With the new Neural Net Google Translation system, the French to English machine translation has improved over the old statistical based method they used previously.  I found fewer need to change the machine translation than before.  There is still a need to hand massage the machine translation though, although it is not as much as before.  I recommend that Wikipedia allow translators to upload their Google translation API key (which is paid for monthly) to their preferences on Wikipedia.  At this stage then the Content Translation system can use the Google Translate to do the machine translation.  I think this is the best compromise, getting the best translation engine involved with Wikipedia translation, and Wikipedia not paying large amounts of money to commercial translation engine companies.
 
 
Other Notes on translating using the Content Translation System of Wikipedia are:
 
 
:1) The Infobox tags don't come over.  You have to manually transfer them to the destination article, and you need to manually translate the language specific argument names, like 'titre=' to 'title='.
 
 
:2) The CITE tags come over but you need to manually change the language specific arguments to them to the destination language equivalents.  You need to do this manually after you publish the article from the Content Translation system.
 
 
:3) You will need to link other articles to your new article, or YOBOT will put an orphan notice up on your new article.
 
 
==Internal Error Errors==
 
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 the Internal Error clears up the gadget has been changed to
 
connect to the Yandex Translation Engine, which is the Russian company.
 
 
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.
 
 
==GoogleTrans gadget now has support for Yandex translation engine==
 
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.
 
 
==GoogleTrans gadget now supports more languages==
 
As of 25/02/2016 the GoogleTrans gadget now supports the following languages (for the GoogleTrans translation engine):
 
 
:Amharic
 
:Corsican
 
:Hawaiian
 
:Kurdish (Kurmanji)
 
:Kyrgyz
 
:Luxembourgish
 
:Pashto
 
:Samoan
 
:Scottish Gaelic
 
:Shona
 
:Sindhi
 
:West Frisian
 
:Xhosa
 
 
In particular, GoogleTrans welcomes the addition of Shona, one of the two main languages of Zimbabwe.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 08:02, 25 February 2016 (UTC)
 
 
 
==Transient IE11 bug fixed up==
 
 
Lately (as of 26/02/2016) it seems that GoogleTrans on ie11 wasn't returning the translation in the popup (but was showing the popup).  This was because of a
 
log message in the code.  This has been fixed up now, and IE11 should work okay with the GoogleTrans gadget.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 19:28, 25 February 2016 (UTC)
 
 
==New Version Of GoogleTrans Gadget, it is an object now==
 
 
A new version of the GoogleTrans gadget is available for use by people interested in the gadget.  To load this new version, unpick the current GoogleTrans in preferences, and put the following line in your <b>common.js</b> file.
 
 
:mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/NewGoogleTrans.js&action=raw&ctype=text/javascript');
 
 
This new version is extensively recoded:
 
 
:a) It is now a Javascript object and there is only one global javascript variable, the name of the gadget object, GT.
 
:b) The code that determines the word under the cursor has been extensively rewritten, although it still follows the same idea, ie., that a SPAN element has dimensions while a Text element does not.
 
:c) The code that determines whether the cursor is within selected text is completely new, and much better.
 
:d) CTRL-ALT translation under the HTML markup still happens as before.
 
:e) You must use the SHIFT trigger for the dictionary lookup popup now.  There is no option anymore to not use the SHIFT key.
 
:f) Further work on the source code is going to weed out explicit references to IE behavior, so GoogleTrans will be support the standards.
 
:g) IE9, IE11, Edge, Firefox and Chrome have been tested.  The browser needs to be relatively modern, IE9 does work, but browsers previous to this may not.
 
 
I propose to test, take feedback, and replace the old version of GoogleTrans in around 1 month's time (middle January 2017). 
 
 
The old version of the Gadget is still running, but will eventually migrate to
 
 
:mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/OldGoogleTrans.js&action=raw&ctype=text/javascript');
 
 
for legacy browsers.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 05:44, 14 December 2016 (UTC)
 
 
==New Version of GoogleTrans Now In Production: 22/12/2016==
 
 
The new version of GoogleTrans, described above, 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 <b>common.js</b> private file:
 
 
:mw.loader.load('//en.wikipedia.org/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.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 19:01, 21 December 2016 (UTC)
 
 
==Bad Cursor Behavior Within Textareas Stopped==
 
As of 11/01/2017 movement of the cursor within textareas to the top or bottom of the textarea has been stopped.  Cursor discovery does not happen anymore within the textarea (or input element).
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 04:19, 11 January 2017 (UTC)
 
 
==Dictionary Lookup in the middle column of Content Translation Has Been Stopped==
 
 
You can now safely hit the SHIFT key in the middle column of the Content Translation page and change a character to Upper Case.
 
 
You can still use the CTRL-ALT key mechanism to translate a paragraph, a part paragraph, or a HTML table while keeping the HTML, as before.
 
 
You can still safely use the cursor hover SHIFT key down mechanism to dictionary lookup words in the left column (origin language column).
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 07:53, 20 February 2017 (UTC)
 
==Has Anyone Noticed That GoogleTrans Is Not Working?(17/05/2017)==
 
 
Has anyone noticed that GoogleTrans gadget is not working.  My Google console for the gadget shows that noone is using the gadget, but
 
I can use the gadget just fine, and when I use the gadget 10 times quickly, enough to get a response on the Google console, there is no progress on the Google use bar.  There doesn't seem to be any Wikipedia action on this, it seems to be that the Google translation console is not working at the moment.
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 06:04, 17 May 2017 (UTC)
 
 
This phenonomen has happened again.  I can use the GoogleTrans gadget just fine, but no activity shows up on the Google Translation console.  I have notified Google on this.  If anyone is having troubles using the gadget, then please report them to me.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 16:09, 17 February 2018 (UTC)
 
 
==GoogleTrans now no longer works in Visual Editor==
 
GoogleTrans no longer works in the Visual Editor (any page with a page parameter including 'veditor=').
 
 
Thanks for the person who alerted me to this problem
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 05:48, 2 August 2017 (UTC)
 
 
==Hausa Added as a language==
 
 
Hausa is now added as a language as it is one of GoogleTranslates 103 current languages.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 05:21, 17 January 2018 (UTC)
 
 
==Language List synced with Google Translate, 103 languages now==
 
Around 30+ languages have been added, including Korean.  I seem to have lost languages at some time.
 
 
The language list for GoogleTrans gadget is now the 103 languages available at Google Translate.  Please tell me if
 
there is something wrong with your language settings, as the position of languages in arrays is crucial for this changes.
 
My testing indicates I have this right now, but if I don't, don't be afraid to let me know.
 
 
Shona and other African languages are back.  Somehow they got dropped somewhere.
 
 
The current list of Google Translate supported languages is [[Google_Translate#Supported_languages | here]]
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 05:47, 18 January 2018 (UTC)
 
==Four Yandex Languages Added(These Only Work On Yandex Translation Engine)==
 
 
:Bashkir(Yandex) ba
 
:Papiamento(Yandex) pap
 
:Tatar(Yandex) tt
 
:Udmurt(Yandex) udm
 
 
have been added as languages to GoogleTrans gadget.  These four languages work only for the Yandex Translation Engine.  If you set any of these
 
languages as the default language and have the Google Translation Engine running, then you will get an "Invalid parameter" popup and you will have to load the page again to get GoogleTrans working.
 
 
You can set the Yandex translation engine in the Language Popup Box, Go to MORE/GOOGLETRANS in the right most menu item of the Wiki page.  As
 
this point you will see a Translation Engine combo box at the bottom of the dialog box.
 
 
Once again, I'm pretty sure I got the array positions right, but if something unintended happens, please contact me.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 02:13, 19 January 2018 (UTC)
 
 
==Hill Mari and Meadow Mari (supported only by Yandex) languages added==
 
 
Hill Mari and Meadow Mari, two regional languages north of the Volga in Russia, have been added.
 
 
These two languages work only for the Yandex Translation Engine.  If you set any of these
 
languages as the default language and have the Google Translation Engine running, then you will get an "Invalid parameter" popup and you will have to load the page again to get GoogleTrans working.
 
 
You can set the Yandex translation engine in the Language Popup Box, Go to MORE/GOOGLETRANS in the right most menu item of the Wiki page.  As
 
this point you will see a Translation Engine combo box at the bottom of the dialog box.
 
 
Once again, I'm pretty sure I got the array positions right, but if something unintended happens, please contact me.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 01:56, 1 April 2018 (UTC)
 
==Google Translation Services Now Available In Content Translation System==
 
 
Great news that Google translation services are now available on Wikipedia. Google has a great translation service and I think this will genuinely help translators who use machine translation appropriately and with much brushing up afterwards.
 
 
I read in the FAQ for this matter that Google Translation services are not available in the enwiki, which is a shame. Therefore people who wish to use Google on the enwiki can continue to use my GoogleTrans gadget which offers both Google and Yandex translation services(Google default). See
 
[[#Integration_With_Wikipedia_Beta_Translation_System:_Now_In_Production_Version_Of_Gadget | here]] for help on the use of GoogleTrans gadget with the Content Translation system.
 
 
GoogleTrans has, if you didn't know it, been offering Google Translation services on the Content Translation System since around October 2015.
 
==GoogleTrans Gadget celebrates it's 10th year anniversary==
 
On Sept 11 2009, around 10 years ago, the GoogleTrans gadget file was created on  the enwiki by administrator CACYCLE.
 
 
As such it is around this date that GoogleTrans gadget was created on the ENWIKI although it was already in operation on the ESWIKI and PTWIKI for around 6 months before this date.
 
 
Thanks to everybody who made this possible and to the people who provided feedback on the use of the gadget.
 
 
GOOGLETRANS seems to be mainly used by wiki translators, who need to know a word in the target or origin language of their translations.  It doesn't seem to be used to actually read a wiki article in a language the reader is learning.  GoogleTrans
 
is an unusual gadget in that it isn't an aid for the wiki editors, and is actually devoted to overcoming language barriers, which is an ancillary but still important goal for a website that provides all information to every one in the world for free, a noble goal in itself.
 
 
GoogleTrans also has a side feature of translating paragraphs (under the markup, that is keeping the html markup) in the Content Translation system of Wikipedia.  The author of GoogleTrans, himself, has used the Content Translation System, and the side feature of the GoogleTrans gadget, to translate 230 articles from the French Wiki to the English Wiki, including around 160 articles on French female athletic champions, much of that corpus I would say.
 
 
GoogleTrans is the sixth most loaded gadget on the enwiki.
 
 
The author of the GoogleTrans gadget would like to thank the leaders of Wikipedia for allowing third party gadgets on the sixth
 
biggest website in the world.  Wikipedia is unique in this way.  No other website would allow this.  Thanks to Jimbo Wales and his staff pour allowing this to happen.  Wikipedia is the greatest achievement of the last 50 years for the Libertarian philosophy, the guiding philosophy of some of the leaders of Wikipedia.
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 23:02, 6 September 2019 (UTC)
 
==Five New Languages Are Supposed To Have Come Online For Google Translate==
 
Five new languages are supposed to have come online in GoogleTranslation.
 
 
While they may be available for the translate.google.com page they are not at the moment available by the API, which
 
GoogleTrans gadget uses.  Therefore, we can't support them at the current moment.  The languages are:
 
 
:Kinyarwanda rw
 
:Odia        or
 
:Tatar      tt
 
:Turkmen    tk
 
:Uyghur      ug
 
 
[[User:Endo999|Endo999]] ([[User talk:Endo999|talk]]) 01:46, 29 February 2020 (UTC)
 
 
== Thanks ==
 
 
Quite a few people have helped test or have made useful suggestions about GoogleTrans.  Some of the prominent ones are:
 
 
:[[User:TheDJ|TheDJ]] - thanks for initial promotion of the gadget and its integration into the existing gadget suite of the enwiki
 
 
:[[User:Cacycle|Cacycle]] - thanks for introducing the SHIFT key requirement to bring up a popup and for actually installing the gadget.
 
 
:[[User:Yug|Yug]] - thanks for great enthusiasm and for suggesting a more simpler layout within the popup.
 
 
:[[User:Was a bee|Was a bee]] - thanks for a lot of testing required to parse Japanese/Chinese according to its actual punctuation marks and for the animated gif in this help file. 
 
 
 
{{DEFAULTSORT:GoogleTrans}}
 
 
[[Category:Wikipedia tools]]
 
[[Category:Wikipedia translation]]
 
 
[[kk:Уикипедия:Гаджеттер/GoogleTrans‎]]
 
[[ja:Wikipedia:ツール/グーグル・トランス]]
 
[[nl:Gebruiker:BarkingFish/GoogleTrans]]
 

Səhifəsinin 00:28, 9 aprel 2020 tarixinə olan son halı

//  _________________________________________________________________________________________
// |                                                                                         |
// |                    === WARNING: GLOBAL GADGET FILE ===                                  |
// |                  Changes to this page affect many users.                                |
// | Please discuss changes on the talk page or on [[Wikipedia_talk:Gadget]] before editing. |
// |_________________________________________________________________________________________|
//
// Translation tool that uses the "Google Translate" API.
// Opens a translation popup for selected text or word under the cursor when pushing the shift button.

// imports [[User:Endo999/GoogleTrans.js]]
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/GoogleTrans.js&action=raw&ctype=text/javascript');