• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum is for release discussion only. Discussions that do not relate specifically to the resource release should be discussed in another, more appropriate forum.
  • 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
#1
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.
 

Vincent

Well-known member
#4
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"
 

Ryan Kent

Well-known member
#5
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.
 

Edrondol

Well-known member
#7
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.
 

Ryan Kent

Well-known member
#12
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.
 

Ryan Kent

Well-known member
#13
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.JPG

Forum first Category Page ForumCategoryPage.JPG

Forum first Thread: ForumPost.JPG

Forum Home Page: ForumHomePage.JPG
 

Ryan Kent

Well-known member
#17
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.JPG
 

Vincent

Well-known member
#18
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 :)
 

Vincent

Well-known member
#19
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 :)
 

Ryan Kent

Well-known member
#20
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?