Archive for February, 2010

How to add google translation to website

We are working on a portal which requires to be translated in more than one language. We thought of using localization techniques in ASP .Net but wanted to make it possible without doing much alteration to the existing site (which is in english). This is when I was going through the google website translator and found this neat widget from translate this. It is just awesome since it asynchronously takes the HTML already generated in the page and translates it. Pretty cool widget and it takes just 8 lines to accomplish this.


<!-- Begin TranslateThis Widget -->
 <div id="translate-this">
 <a href="http://translateth.is/">Translate</a></div>

 <script type="text/javascript" src="http://www.google.com/jsapi"></script>

 <script type="text/javascript" src="http://x.translateth.is/translate-this.js"></script>

 <script type="text/javascript">
 TranslateThis();
 </script>

 <!-- End TranslateThis Widget -->

Hope this helps.

Happy Programming!!!

Cheers,

Raja

Advertisements

How to add keyboard navigation for Jquery UI Tabs

We make use of Jquery UI a lot and their widgets are just awesome. One feature which was missing in Jquery (correct me if I am wrong) UI tabs was the option to use arrow keys or any key for tab navigation. So wrote this small script to make it happen. This concept can be modified in any manner so that we can give “Google Reader” like keyboard shortcut features in our web page.


$('body').keyup(function(e) {

 var direction = null;

 // handle cursor keys
 if (e.keyCode == 37) {
 // slide left
 direction = 'prev';
 } else if (e.keyCode == 39) {
 // slide right
 direction = 'next';
 }
 if (direction != null) {
 var totaltabs = $('#tabs').tabs('length'); //gettting the total # of tabs
 var selected = $('#tabs').tabs('option', 'selected');//getting the currently selected tab
if (direction == 'next') {
 if (selected <= totaltabs - 1)
 $('#tabs').tabs('select',selected + 1)
 }
 else
 {
 if (selected != 0)
 $('#tabs').tabs('select',selected - 1)
 }
 }
});

Hope this helps.

Happy Programming!!!

Cheers,

Raja