Пример #1
0
 triggers.register("translate",function(source,destination,privacy,input){
   if(!input) return
   input = input.trim()
   var args=ArgumentHelper(1,input)
   if(args[1]) {
     var langs=args[0].split(':')
     translate.text({
         input:langs.length>1?ArgumentScrub(langs.shift()):false
         ,output:ArgumentScrub(langs[0])
       },ArgumentScrub(args[1]),function(translatedText){
         obj.say(destination,translatedText)
       }
     )
   }
   else {
     translate.text({
       input:false
       ,output:'English'
     },ArgumentScrub(input),function(translatedText){
       obj.say(destination,translatedText)
     })
   }
 })
Пример #2
0
	this.triggers.translate = function(name,to,message,languages,text) {
		//figure out who to respond to
		//if it was a private message to me, respond to the person
		//if it was to a room and not me specificall, reply in the room
		var destination = to === this.nick
			? name
			: to
		
		var client = this
		if(text) {
			var pair = languages.split(/[:]/)

			translate.text({input:pair[0],output:pair[1]},text,function(txt) {
				//respond with the translated test, decoding the html entities
				client.say(destination,html.decode(txt))
			})
		}
		else {
			translate.text(languages,function(txt) {
				//respond with the translated test, decoding the html entities
				client.say(destination,html.decode(txt))
			})	
		}
	}
Пример #3
0
var t = require('translate');
t.text("this is a test", function(err, txt) { 
  console.log(txt); 
});
  
t.text("this isn't a test", function(err, txt) { 
  console.log(txt); 
});
Пример #4
0
/* 
  check out the translate.js project for more information
  http://github.com/marak/translate.js/

  requires installing the translate.js module via
  
  sudo npm install translate

*/

var say = require('../lib/say');
var translate = require('translate');

translate.text('Yo quero tacos por favor', function(result){
  say.speak('Alex', result);
});