function I18n() {}

I18n.prototype = {
	_: function(key, variables) {
		var result = '';
		
		// Se recupera el texto adecuado
		$.ajax({
			type: "POST",
			url: "/ajax_i18n.php",
			data: {key: key, variables: JSON.stringify(variables)},
			success: function (data) {
				if (data.errorCode) {
					alert(data.errorMessage);
					return;
				}
				
				result = data.text;
			},
			dataType: "json",
			async: false
		});
		
		
		return result;
	},
	
	tr: function(text) {
		var result = '';
		
		$.ajax({
			type: "POST",
			url: "/messagesJs.php",
			data: {text: text },
			success: function (data) {
				result =  data.translation;
			},
			dataType: "json",
			async: false
		});
		
		return result;
	},
	
	linkTo: function(link) {
		var locale = location.href.split("/");
		return locale[3] + "/" + link;
	}
	
}