/**
 * @short Translation function.
 *
 * It needs two preious init calls:
 *
 *  addTranslations(trans) - A dict like this {'es':{'hello':hola},'fr':{'hello':'alo'}}, 
 *                           may be called several times
 *
 *  setLanguageCode(code) - the language code, like 'es'
 *
 * Allows an arbitraty number of arguments that will replace (as Strings) the {{1}}, {{2}}, {{3}}...
 */
var _=function(){
	//alert(languageCode)
	var s=arguments[0]
	ns=s
	try{
		ns=translations[languageCode][s]
		if (!ns)
			ns=s
	}
	catch(e){
		ns=s
	}

	// Now substitutions
	for (i=1;i<arguments.length;i++){
		ns=ns.replace('{{'+i+'}}',String(arguments[i]))
	}
	return ns
}

var setLanguageCode = function(code){
	languageCode = code
}

var addTranslations = function(trans){
	translations = trans
}



