I have to say up front that my skill with languages is very poor. It is something I have struggled with since I was at school when I sat in my French exam blankly staring at the examiner who was expecting me to impress him with some fluent expression of how nice the weather was (or something like that - I have blanked most of it out of my mind). However, one thing that I am pretty good at is testing and tracking different things on my sites.
If you have any kind of analytics package installed on your b2evolution blog, you will probably have more data than you know what to do with about how many visitors come to your site, how long they stay and the pages they visit etc. One of the things that interests me is looking at where the visitors to my site are coming from and Google Analytics has a very nice map overlay allowing you to pinpoint geographically where your visitors access your website from. You can also click on the map and drill down even further to individual cities and towns which is great if you are looking to target specific regions with any of your SEO effort.
Follow up:
Here is the Map Overlay for this site:
As you can see from the map, the visitors to my site come from all over the world (57 countries to be exact). As this site is written totally in English I had to ask myself whether the people visiting were able to consume the content in any kind of meaningful way. Looking into this a little further, I can see that the top two countries hitting this site are the USA and the UK, which are both English speaking countries. So at least I know a high percentage will be able to read the content on this site. However, I want there to be as few barriers as possible to people getting the most out of this blog as possible. The solution to this turns out to be very easy.
Enter Google Translate Tools
Using Google’s Translate Tools you can simply add a little snippet of code to your site to add Google’s website translator to your web pages giving your visitors the ability to instantly translate your content into their chosen language. I added this to the sidebar of my site by simply adding a Free HTML Widget to my sidebar and entered the following code:
Code:
<div id="google_translate_element"></div><script> | |
function googleTranslateElementInit() { | |
new google.translate.TranslateElement({ | |
pageLanguage: 'en' | |
}, 'google_translate_element'); | |
} | |
</script><script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> |
This code specifies that my website content is in English so if your content is in a different language head on over to the Google’s Translate Tools page and generate the code for your language.

Subscribe: 



For different languages you would have to change the "pageLanguage" part in the snippet only.
Would be useful to get this filled out by b2evo itself (e.g. via widget plugin), where it could use the first part of the Item/Blog locale.
However, when viewing multiple items, there might be different locales involved after all.
I could imagine the tool to support this via "lang" attributes on the site: i.e. Google would just determine the source locale/lang based on this attribute.
@Daniel I think wrapping this up in a widget would be a pretty cool idea. Are you talking about using the php locale_lang() to populate the pageLanguage part ?
Cheers
Lee
Hi Lee,
I've added this code. It appears in the HTML of the page, but, for some reason no translate button appears.
Any ideas?
Thanks,
Mark
Hi Mark,
Thanks for commenting. Well spotted. There was an error in the code due to me writing the post in Markdown before converting it to HTML. The conversion messed up a bit of the code.
The example has now been updated so give it a try now.
Cheers
Lee
I'll just note that Google Translate, though superior to other online translators, does a very bad job translating from one language to another. Also, it only makes sense that only people who understand English visit your site; your site most likely wouldn't show up on any decent search engine when they enter keywords in their native language.
Excellent idea.
I don't think you really need to wrap it up in a widget as it wouldn't add anything on top of what FreeHTML offers.