• 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

Vincent

Well-known member
Hello,

If you want to add Google Translate to your website, then search the following code in template called navigation:
Code:
<!-- extra tabs: middle -->

Before that line, paste the following code:
Code:
	 <!-- Google Translate -->
		<li class="navTab upgrade PopupClosed">
			<a href="http://translate.google.com/translate?u={$logoLink}" class="navLink">Google Translate</a>
		</li>

Now a "Google Translate" tab will appear in your navbar.
 
Hello,

If you want to add Google Translate to your website, then search the following code in template forum_list:

Can someone plz share the path to find forum_list? What type of file is it?

Sorry I am completely unfamiliar with these files.
 
Can someone plz share the path to find forum_list? What type of file is it?

Sorry I am completely unfamiliar with these files.

It is a template, to go there, follow this path:
Admin Control Panel -> (Login) -> Appearence -> Templates -> Search for "forum_list"
 
It works perfectly! It's almost instant too. I think this simple template change would be a huge benefit to any forums.

Thanks Vincent for educating me a bit more about XF and sharing.
 
Instead of altering the forum_list with all that code, I created a new template called "google_translate" and added <xen:include template="google_translate" /> to the forum_list instead. I know it's doing the same thing, but if I have to revert the forum_list later I only have to add the one line of code.

But damn does it work great!

Edit: By the way, if you are reading this and wondering what's going on, the original instructions had us altering the forum_list template. This has changed, invalidating my post.
 
If i would like to have the code into the navbar? How do i have to alter the Code? Thanks
 
You are correct. For the tool to be more useful we need to figure out a way for it to exist on all pages, especially the selected forum threads.

With that said, it is still of use. If a user clicks on the "Translate" link, a window opens asking users for the name of the page they wish to translate. If they copy and paste the current forum URL, a new window opens which translates not only the current page, but the entire website.

What's needed is for someone with the knowledge to add this form of the translator to the page.
 
Some example shots from my forum. My forum is in English as that's the only language I understand. I chose to change it to Chinese for this test.

Forum Main Page ForumMainPage.webp

Forum first Category Page ForumCategoryPage.webp

Forum first Thread: ForumPost.webp

Forum Home Page: ForumHomePage.webp
 
It appears that the google translator just translates 1 page, I'm going to search how to do the others too.
 
I'd suggest having a translate tab in the navbar so it's on each page. Maybe in the footer if you want it less prominent.
 
I can share a bit of information which may help. If you look at the second Google Translate bar in the screenshot I am attaching now, it has a specific appearance. That type of Google Translate bar only translates the page you are viewing. As soon as you change pages within the site, you lose any translations. This is the type of Google Translate Bar I have currently on my site.

If you look at the first Google Translate bar in the current attachment, it matches the bar from the screenshots I attached above. This bar, once it appears, will stay as you surf the site. You can change from forums to home page, read various posts, etc and everything will be translated. THIS is the type of bar desired.

Unfortunately when I went to the Google site to download the translator, the code I posted initially in this thread is what I received. The other translator I located on a website http://andreasviklund.com/ On that website, the right side of his website remains constant no matter what page you are viewing, including the forums. XF is not designed in that matter.

I hope this information may be of some value. Thanks again for your efforts!

GoogleTranslate2.webp
 
I'd suggest having a translate tab in the navbar so it's on each page. Maybe in the footer if you want it less prominent.

I have done that, but it just doesn't work.

I can share a bit of information which may help. If you look at the second Google Translate bar in the screenshot I am attaching now, it has a specific appearance. That type of Google Translate bar only translates the page you are viewing. As soon as you change pages within the site, you lose any translations. This is the type of Google Translate Bar I have currently on my site.

If you look at the first Google Translate bar in the current attachment, it matches the bar from the screenshots I attached above. This bar, once it appears, will stay as you surf the site. You can change from forums to home page, read various posts, etc and everything will be translated. THIS is the type of bar desired.

Unfortunately when I went to the Google site to download the translator, the code I posted initially in this thread is what I received. The other translator I located on a website http://andreasviklund.com/ On that website, the right side of his website remains constant no matter what page you are viewing, including the forums. XF is not designed in that matter.

I hope this information may be of some value. Thanks again for your efforts!

View attachment 11320

I will try something with that :)
 
Guys, I have found something :)

We are working in the template navigation
BEFORE THIS CODE
Code:
<!-- extra tabs: middle -->

Add this code
Code:
		<!-- Google Translate -->
			<li class="navTab upgrade PopupClosed">
				<a href="http://translate.google.com/translate?hl=nl&sl=auto&tl=select&u={$logoLink}" class="navLink">Google Translate</a>
			</li>

It will look like this:
http://www.hlxbans.net/

You can change the "auto" and "af" to every language code you'd like :)
 
It's looking good so far. One minor note. If I select the Google Translate tab, it brings up the Google Translate bar which is great, but then it has the Afrikaans language selected and it automatically translates to Afrikaans. I would like the first box (Translate from:) to begin as English and the second box (Translate into:) to be Select Language.

I tried replacing the "af" with "en" but then the page translated into a language called Engels (?English in another language). I am guessing that some codes might be left in from your language based on my short visit to your site. When I try to translate to "Engels" an error occurs which is unreadable.

Edit* Upon review the challenge is the Google Translate tab in the menu next to forums doesn't merely bring up the Google Translate window, it automatically makes the default translation which is not good. We don't know which language the user will select, so it should be left up to each user to make that choice. Is there a way to not selecting the Google Translate menu selection equivalent to pressing the "translate" button?
 
Top Bottom