XF 2.0 Add a Google translator button

Netsky

New member
Hi,

I'm a new Xenforo user and i need to add a Google translator button in our international forum :
https://theminixforum.com

I searched and found solutions but it worked on old 1.5 version and i can't find the good way to add this button.

I found some code to add from Google website itself but i don't know if it's the good way to work, where to post this code.

Code:
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Thanks for your help ! :)
 
A really useful code snippet!
PAGE_CONTAINER template after </head> would be the right place for us here.
Unfortunately, it blocks the "reactions" of mobile devices in XenForo 2.1.2 (Responsive) as used here.
Does anyone know how to fix it?
 
I just ran into this problem too. After installing the Select Language, the reaction emojis have reverted to the default "Like" only. It would be great if we could use both of these fine features. Did anyone find a solution to this?
 
I just ran into this problem too. After installing the Select Language, the reaction emojis have reverted to the default "Like" only. It would be great if we could use both of these fine features. Did anyone find a solution to this?
@Masetrix @SyTry I LOVE this idea, especially for a global site..so I had to go and try it too and the translations work perfectly! However, @WavMixer2 is right... for some reasons it only allows you to "Like" media all your other reactions become unavailable to select, even though old posts retrain them, until the google translate code is removed.

Since reactions are popular, I've turned that off for now. Perhaps a solution can be worked out or if it's even possible -- maybe we can commission a add-on dev to work some XF magic to make them both work? That would be awesome!

Thanks for sharing the code and idea @Netsky
 
@Masetrix @SyTry I LOVE this idea, especially for a global site..so I had to go and try it too and the translations work perfectly! However, @WavMixer2 is right... for some reasons it only allows you to "Like" media all your other reactions become unavailable to select, even though old posts retrain them, until the google translate code is removed.

Since reactions are popular, I've turned that off for now. Perhaps a solution can be worked out or if it's even possible -- maybe we can commission a add-on dev to work some XF magic to make them both work? That would be awesome!

Thanks for sharing the code and idea @Netsky
We need to look at this yes ^^
 
We need to look at this yes ^^
is that possible to do? or to at least identify how google translate is breaking it? Ideally, if GT cannot "read" that popup - it should just ignore it and not translate it. It's odd to my no programming skills at all self ... that the little bit of GT translate code breaks that one piece of XF.
 
is that possible to do? or to at least identify how google translate is breaking it? Ideally, if GT cannot "read" that popup - it should just ignore it and not translate it. It's odd to my no programming skills at all self ... that the little bit of GT translate code breaks that one piece of XF.





Hth... ;)
 
Ok, I did a couple of tests. Unfortunately, it doesn't work as expected.
You can (see screenshot my "like"=>"Bewerten" in german language.) prevent the "likes" from being translated,
1593251980937.webp

but you cannot prevent the extended likes from being moved to bottom, see the next screenshots.

Codeview:
1593253210155.webp

Userview:

1593252686931.webp
 
The only solution I have found so far would be the posting that should be liked to scroll up to the Google bar, then the liking works, but only if the likebutton is not translated lol see screenshot

1593256834348.webp
 
The only solution I have found so far would be the posting that should be liked to scroll up to the Google bar, then the liking works, but only if the likebutton is not translated lol see screenshot

View attachment 229246
hmmm could someone share the updated code... so i can tinker? This is almost worthy of XF dev talk... if they could find a way to make it an included option via google that didn't interfere with likes (I don't see it bothering anything else?) --- I mean... it would be a cool integration... very effective for global communities.
 
Top Bottom