localizer=function(){
	this.parsed=0;
	this.init=function(){
		this.langObj={};
	}
	this.parseLang=function(){
		if(this.parsed==0){
			if(typeof(__langstr) == 'string'){
				this.langObj=_s2o.unserialize(__langstr);
			}
			this.parsed=1;
		}
	}
	this.sprintf=function(){
		var num=arguments.length;
		var oStr=arguments[0];
		for(var i=1; i<num; i++){var pattern="\\{"+(i)+"\\}";var re=new RegExp(pattern,"g");oStr=oStr.replace(re,arguments[i]);}
		return oStr; 
	}
	this.tr=function(){
		if(arguments.length==0) return '';
		else{
			this.parseLang();
			if(arguments[0].indexOf('/')>-1){textID=arguments[0].split('/');groupID=textID[0];unitID=textID[1];}
			else{groupID=this.currentGroupID;unitID=arguments[0];}
			targetText=this.langObj[groupID][unitID];
			if(arguments.length==1) return targetText;
			else{args=arguments;args[0]=targetText;return this.sprintf.apply(this,args);}
		}
	}
	this.plural=function(unitID, count){
		if(arguments.length==0) return '';
		else{
			if(arguments.length==1){unitID=unitID+'_plural';return this.tr(unitID);}
			else{
				if(count>1) unitID=unitID+'_plural';
				var args=[];
				args[0]=unitID;
				for(var i=2;i<arguments.length;i++){args.push(arguments[i]);}
				return this.tr.apply(this,args);
			}
		}
	}
	this.formatPrice=function(price,currency){
		if(currency=='&#36;') return currency+price.split(',').join('.');
		else return price.split('.').join(',')+currency;
	}
	this.currentGroupID=null;
	this.openGroup=function(groupID){
		this.currentGroupID=groupID;
	}
}
var _localizer = new localizer();
_localizer.init();