1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.
    Dismiss Notice
  3. 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

Discussion in 'Template Modifications [Archive]' started by Vincent, Feb 19, 2011.

  1. Vincent

    Vincent Well-Known Member


    If you want to add Google Translate to your website, then search the following code in template called navigation:
    <!-- extra tabs: middle -->
    Before that line, paste the following code:
    	 <!-- Google Translate -->
    		<li class="navTab upgrade PopupClosed">
    			<a href="http://translate.google.com/translate?u={$logoLink}" class="navLink">Google Translate</a>
    Now a "Google Translate" tab will appear in your navbar.
    TonyHoang, Reedswood, yavuz and 3 others like this.
  2. Ryan Kent

    Ryan Kent Well-Known Member

    Thanks so much for sharing how to make this template mod!!!
  3. Ryan Kent

    Ryan Kent Well-Known Member

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

    Sorry I am completely unfamiliar with these files.
  4. Vincent

    Vincent Well-Known Member

    It is a template, to go there, follow this path:
    Admin Control Panel -> (Login) -> Appearence -> Templates -> Search for "forum_list"
  5. Ryan Kent

    Ryan Kent Well-Known Member

    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.
    Vincent likes this.
  6. Allan

    Allan Well-Known Member

    Good job, thank you Vincent ;)
  7. Edrondol

    Edrondol Well-Known Member

    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.
  8. Edrondol

    Edrondol Well-Known Member

    Hmm. On testing it only does the one page. I'll have to change this to be able to do all pages.
  9. Vincent

    Vincent Well-Known Member

    I guess that when it's in the footer it will translate all pages. Would you mind trying?
  10. bogus

    bogus Guest

    If i would like to have the code into the navbar? How do i have to alter the Code? Thanks
  11. RobParker

    RobParker Well-Known Member

    Very cool but as mentioned, it only does it on the forum home page so not that useful at the minute.
  12. Ryan Kent

    Ryan Kent Well-Known Member

    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.
  13. Ryan Kent

    Ryan Kent Well-Known Member

    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
  14. Vincent

    Vincent Well-Known Member

    I'll have a fix ready in a few hours. I'm at the iPad now :p
  15. Vincent

    Vincent Well-Known Member

    It appears that the google translator just translates 1 page, I'm going to search how to do the others too.
  16. RobParker

    RobParker Well-Known Member

    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.
  17. Ryan Kent

    Ryan Kent Well-Known Member

    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!

  18. Vincent

    Vincent Well-Known Member

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

    I will try something with that :)
  19. Vincent

    Vincent Well-Known Member

    Guys, I have found something :)

    We are working in the template navigation
    <!-- extra tabs: middle -->
    Add this 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>
    It will look like this:

    You can change the "auto" and "af" to every language code you'd like :)
  20. Ryan Kent

    Ryan Kent Well-Known Member

    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?

Share This Page