Hey ppl, i have the following scenary:
<div class="maindiv">
<div class="msg">some text</div>
...
<div class="msg">some other text</div>
</div>
I'd like to take the text of each 'msg' class div and translate it using Google API.
I've made the following JS function:
function translateTimeline(){
var lang = $('#timelineLenguage').val();
var translation;
$(".msg").each(
function(i){
translation=google.language.translate($(this).text(), "", lang,
function(result) {
if (!result.error) {
$(this).text(result.translation);
}else{
alert('Cannot translate tweet. Try again later');
}
});
});
return false;
};
which is not working..
This was all i could make with my limited JS/jQuery skills..
Thx in advance for your help and time :)