Skip to content

Commit adfe8d8

Browse files
committed
edit translate
1 parent 1a5fa47 commit adfe8d8

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

translate.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
define('Translator', function(){
22
function Translator(locale){
33
this.locale = locale;
4-
this.onResult = {'id' : '', 'text' : ''};
4+
this.onResult = null;
55
};
66

77
Translator.prototype.translate = function(recognitionResult){
@@ -13,10 +13,9 @@ define('Translator', function(){
1313
lang: recognitionResult.locale + '-' + this.locale
1414
},
1515
success: function(result) {
16-
translatevariable.onResult.text = result.text;
17-
translatevariable.onResult.id = recognitionResult.id;
18-
console.log(translatevariable);
19-
}
16+
if(translatevariable.onResult){
17+
translatevariable.onResult({id : recognitionResult.id, text : result.text});
18+
}
2019
});
2120
}
2221
return Translator;

0 commit comments

Comments
 (0)