Thursday, January 15, 2009

Google Language API Round 2

Just a few days ago I Blogged about Google's Language API having character limitations which kind of makes the API almost useless to those with larges amounts of copy on their pages, say much more than 5000k characters.

Now after a bit of research and "farting" around with things, I found a solution that is available using today's amazing Ajax libraries.

JQuery, which just may be (in my eyes) the top dog of all the Ajax libraries available to the public with an Open-Source MIT-License has a tranlation plug-in available which can be found right here as well as some how to use it information along with bug issues and fixes. If you have any type of experience working with JQuery, you probably know how easy it is to develop some incredible web application features.

Here's what you need to do so you can implement Google's Language API and JQuery's Translation Plug-in onto your web site.

1. Start off by grabbing the zipped files here.
2. Create a new folder some where within your site or even create a new site directory.
3. Now create another directory for all the JQuery and unzip Language API into the newly created directory.
4. Now create a new page (HTML, Coldfusion, PHP, JSP or whatever you wish) or duplicate an already existing page within your web site so you can play around with the API.
5. Include all 4 scripts into the head of your page:
6. Now add a bunch of text to your page and I mean a bunch.
7. Pick a place for the language selector to be put and add a div with an id of jq-primaryNavigation.
8. Finally save your work and give it a go. If all goes as planned you should be able to translate any text inside the body of your web site just by selecting a language from the select list and have the selected language be remembered throughout the visit of your web site until your browser session is ended.

I found a couple things that put a cripple on both, Google's Language API and JQuery's Translation Plug-in.
1. This one actually goes along with many other Ajax Libraries. If you still use Adobe GoLive, don't even bother using any of the JavaScript features or scripts that GoLive generates for you. It just clashes with anything and everything.
2. Stay away from the menu maker widget called Menu Machine which again, is a plug-in for GoLive and again, causes all kinds of trouble. It's just a good idea to stay away from GoLive NO MATTER WHAT!
3. Google say's that you may need to have the meta equiv="Content-type" content="text/html; charset=utf-8" block in your source although it should be there in any sense.

I believe that's it! Hope I didn't forget anything. But if I did, please feel free to correct me as I'm sure all will do anyway and here's a working example for all to see and fiddle.

- Pete

No comments: