• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Adding Google Translate to your xenForo Website

I've changed the code in the above post to take your default language.
It cannot be "select language" because it is not an option.

Now it goes automatically to the lang of your browser :)
 
I am *guessing* this is the language for ?netherlands that keeps coming up. Also, not sure if you caught it but I adding an *edit* at the end of my last post. The moment I press Google Translate I can't read a thing and have to re-type the address in the browser. I can't even translate back to original language without getting an error (which I can't read).
 
Well, I updated the code

Try that, and if something's wrong we'll chat :D
I guess it should work now mate.
 
I looked in the 'navigation' template but the text below isn't there...
<!-- extra tabs: middle -->
It should be there around line 68 on a default installation.

FYI, I didn't care for the way this solution worked and went with an alternative.

The biggest challenge with this solution is that it logs the user out of the forums any time a page is translated. This is due to how Google decided to translate the page.
 
I've added this to my site, but did it a bit different. I added the translate to the right of the forum title as shown in the screenshot. If you don't care for the horizontal look, create your own here http://translate.google.com/translate_tools

Edited template ad_above_content and below the only line there I added
Code:
<div class="google">
<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en',
    layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL
  }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>

Then in extra.css I used
Code:
/* google translate */
.google {    
float: right;
margin-top: -35px;
}

It doesn't seem to be causing any issues with logging in or out for me so far.
 

Attachments

  • google-translate.webp
    google-translate.webp
    10.4 KB · Views: 144
Top Bottom