I have a function that is supposed to return the google detected
language but when I tell my function to return the language and then
console.log the function, the console returns undefined. If I
console.log the language inside the function, it works.
Any ideas?
//Doesn't Work
var monkey_fur = function(str) {
google.language.detect(str, function(result) {
if (!result.error) {
var language = 'unknown';
for (l in google.language.Languages) {
if (google.language.Languages[l] ==
result.language) {
language = l;
break;
}
}
return language;
}
});
}
console.log(monkey_fur(text));
//Works
var monkey_fur = function(str) {
google.language.detect(str, function(result) {
if (!result.error) {
var language = 'unknown';
for (l in google.language.Languages) {
if (google.language.Languages[l] ==
result.language) {
language = l;
break;
}
}
console.log(language);
}
});
}
--
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en.