Extension talk:Google Translator
1.30
editIt was not working with version 1.30, I edited the code to version 0.3
Subversion
editCan someone help me getting the files on the SVN server thing? I tried, but I keep getting access denied (403) errors.
- You mean on Wikimedia's SVN server? See Commit access requests, though it would be better if you published your code on-wiki first for public review. Max Semenik 16:08, 17 June 2010 (UTC)
- Code is published, I will request access at a later stage, thx for the info though Joa ds 16:18, 17 June 2010 (UTC)
- Neat, I made a couple of minor corrections. Max Semenik 16:47, 17 June 2010 (UTC)
- Code is published, I will request access at a later stage, thx for the info though Joa ds 16:18, 17 June 2010 (UTC)
replace toolbar?
edithi, your extension works wonderfully and the way it fetches the translated text with ajax is like a magic! My only concern is that the toolbar may be disturbing. This toolbar is exactly the same as the translation toolbar in Google Chrome, and it's been one of the most "disliked" functions in Google Chrome User Forums. Some similar toolbars are placed at the bottom and make it lesser disturbing. While I have totally no idea about the google ajax, is it possible to move the toolbar? --Wmama 19:47, 30 September 2010 (UTC)
- It is indeed calling the translate bar, but you can switch it off for certain webpages as you desired, so shouldn't be much of a problem--Joa ds 21:58, 17 August 2011 (UTC)
Showing the Translation Box On-Demand
editI'm using the CustomNavBlocks extension to control my sidebar, so Translator box doesn't show up on its own. How do I get it to display on a page? Thanks --Skew 18:33, 24 February 2011 (UTC)
Using with MW 1.18.0
editI installed Google Translator on my wiki and had no problems with it other than formatting. The toolbar stuck out into the page (using Vector) when I used it with a blank list of languages to get all languages. The problem is the entries "Chinese (traditional)" and "Chinese(simplified)" make it really wide. So I went to the Google toolbar configuration tool, selected all languages, then got rid of the two Chinese ones. Now I have almost all the languages and a toolbar that fits in the sidebar (sorry, China; only a billion people I'm ignoring).
The other problem was the branding "Powered by Google Translate" under the toolbar was sticking into the page. I fixed that with some CSS to wrap the text around the Google logo. At Google there is an option to show just the toolbar without the branding (has a little G badge), but it makes the toolbar wider. You could make this change to GoogleTranslator.class.php. I added the CSS for wrapping to the main article, but it is:
a.goog-logo-link img {display: block}
Edit request
editMy pending changes are stuck - please remove the text I've added to the beginning of the Intro (ending with "Signed by HTFFanBrandon04"). HTFFanBrandon04 (talk) 05:03, 26 March 2012 (UTC)
- I've accepted your revert of it, but I see no technical justification of it because this extension does not modify the database.Jasper Deng (talk) 05:15, 26 March 2012 (UTC)
Adding more languages
editI need basically all languages. How does that code look?
- In localsettings.php, just leave the list of languages blank like this and you will get everything:
$wgGoogleTranslatorLanguages = ′ ′;
Error with MW 1.21.1
editI was getting an error about a function call. I found out that you have to go into the file GoogleTranslator.class.php and comment out the following line, which isn't necessary and uses a function that is no longer supported:
wfLoadExtensionMessages( 'GoogleTranslator' );
Brted (talk) 03:02, 18 June 2013 (UTC)
- This fixed it for me too. I'm going to suggest we remove the line from the reference source code on Extension:Google_Translator. As I understand it, this would mean burning support for MW 1.15 (see r52503) but that seems a fair exchange for adding support for 1.21+. Objections, anyone? AL286 (talk) 15:32, 8 December 2014 (UTC)
- In the absence of any objections, I've made this change to the code (plus the HTTPS compatibility one mentioned below) and updated the version number of the extension to 0.2. AL286 (talk) 15:45, 15 December 2014 (UTC)
Error in Mediawiki 1.23
editWhile installing the extension on Mediawiki 1.23, I got the following error.
Fatal error: Call to undefined function wfLoadExtensionMessages() in /u01/UAG/apache/htdocs/old_TCS_Rewardz_2.2/extensions/GoogleTranslator/GoogleTranslator.class.php on line 14
Solution - Comment "wfLoadExtensionMessages( 'GoogleTranslator' );" from the code. It did not have any impact on the translation.
HTTPS compatibility
editCurrently the extension has poor compatibility with SSL. In modern browsers, the user will get a security warning if it's used in an HTTPS page because it attempts to retrieve the Google Translate script over HTTP. Changing the script reference in GoogleTranslator.class.php to a protocol-relative one seems to work:
<script src=\"//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit\">
Does anyone have any objection to me making this change in the reference source on the article page for this extension? AL286 (talk) 12:55, 8 December 2014 (UTC)
- In the absence of any objections, I've made this change to the code (and removed the call to wfLoadExtensionMessages() as discussed above) and updated the version number of the extension to 0.2. AL286 (talk) 15:45, 15 December 2014 (UTC)
Parse Error
editI get this... but I do not see what syntax is wrong?
Parse error: syntax error, unexpected end of file in /home/n117056/public_html/extensions/GoogleTranslator/GoogleTranslator.php on line 69
I added };
But get these messages:
Notice: Undefined variable: wgGoogleTranslatorOriginal in /home/n117056/public_html/extensions/GoogleTranslator/GoogleTranslator.php on line 63 Notice: Undefined variable: wgGoogleTranslatorLanguages in /home/n117056/public_html/extensions/GoogleTranslator/GoogleTranslator.php on line 64
- I just restored availability of these configuration variables and I fixed these notices. --Sphax3d (talk) 21:34, 28 February 2023 (UTC)
Mediawiki 1.31.5
editInstallation at mediawiki 1.31.5 was not possible . I found a better solution without adsense and with mediawiki headscript.
a.<di-v id="google_translate_element"> </di-v> into the sidebar of the template
b. into localsetting as described in the HeadScript-extension
<script> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script> <script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
see also https://www.w3schools.com/howto/howto_google_translate.asp
Example : www.spiritwiki.de
Limiting languages doesn't work
editI have set up the language choices to be limited as in the provided example, ie:
$wgGoogleTranslatorLanguages = 'nl,fr,de';
However, the dropdown menu still shows ALL languages. What have I missed?
I tried to provide a link to my web site so you can see it, but the editor helpfully bans external links.
Also, it says for a list of supported languages, to click a link (that i can't refer to here), however that link leads nowhere. Where can one find a list of supported languages? Davec (talk) 22:10, 7 January 2022 (UTC)
- Hi Davec! I ran into the same issue and it seems at some point the extension page was changed and the language options are hardcoded as everything (empty), you can go to an older version to see how it used to be (should be?). -Bryandamon (talk) 03:31, 11 January 2022 (UTC)
- Hi Davec and Bryandamon. I just restored the original behavior with the two configuration variables. --Sphax3d (talk) 21:41, 28 February 2023 (UTC)
Translate-bar at the top always visible in Firefox
editMediawiki 1.37.4 - php7.4 : spiritwiki.info
The translator functions, but in Firefox it is always on. I can of course klick at "disable translation for this site" - but the visitors want like that (in other browsers like edge, chrome an opara this doesnt happen). Manbu (talk) 18:06, 3 August 2022 (UTC)
- For me helped a change in the GoogleTranslator.php :
- function googleTranslateElementInit() {
- new google.translate.TranslateElement({pageLanguage: 'de', layout: google.translate.TranslateElement.InlineLayout.VERTICAL}, 'google_translate_element');
- }
See also Jsfiddle Gtranslate Manbu (talk) 11:29, 4 August 2022 (UTC)