2009年10月6日 星期二

My notes of jquery-translate usage

Effects: 
Automatic distinguish between Simp Chinese and Trad Chinese then translate to desired language. Few steps to enable localization functionality.

Requirement:
#1. jquery Library. get from here.
#2. jquery-translate. get from here.

Procedures:
#1. Include all necessary JS file.
#2. Make sure all require JS file store in inc folder correctly.
#3. Content of wraper.trans.js

var lang = window.navigator.userLanguage || window.navigator.language ;
var autolang=lang.toLowerCase();
var trans2CN = (autolang == "zh-cn") ? true : false;
trans2CN = true;
$(document).ready(function() {
if(trans2CN){
document.navagation.src='/images/pic.gif';
$('body').translate('zh-CN');
}
});