22nd January 2011, 20:26
#10
1 out of 1 members found this post helpful.
Atunci poti face in felul urmator
Cod:
<script src="http://www.google.com/jsapi?key=ABQIAAAARtfazj5XcNFOFzBir0AmkxQvZHi5Z2qeqRnpT_zuEAl2yvinaRT2bxOtQxlgMNk7Z-kuZhjhv3y57g"></script>
<script type="text/javascript">
google.load("language", "1");
var translatedText = new Array();
window.onload = function(){
google.language.translate('my text goes here', 'en', 'ro', function(x) {
addTranslation(x.translation);
});
google.language.translate('my second text goes here', 'en', 'ro', function(x) {
addTranslation(x.translation);
});
google.language.translate('my third text goes here', 'en', 'ro', function(x) {
addTranslation(x.translation);
finalFunction();
});
function addTranslation(text){
translatedText[translatedText.length] = text;
}
function finalFunction(){
alert(translatedText);
}
}
</script>
Ce trebuie sa ai in vedere:
1. In ultimul translate sa apelezi functia finalFunction
2. in interiorul functiei finalFunction, translatedText va fi un Array ce va contine toate textele traduse. De acolo poti face mai departe cererile ajax de inserare in baza de date.