Salve gente,
Oggi, per necessità lavorative, mi sono ritrovato a cercare qualche tool che mi facilitasse l’uso del servizio di traduzione fornito da google. (google translate)
Facendo un po di ricerche ho trovato un’api non officiale che, purtroppo, non è più sviluppata ( per info eccolo ). Continuando a googlare ho visto che google a rilasciato un api ufficiale che tuttavia ha delle grandissime limitazioni.
Eccoci quindi alla mia implementazione.. La mia api, necessita di php ed è formata da questa cortissima funzione :
function gTranslate($from,$to,$text) {
$result = getPage(“http://translate.google.it/translate_a/t?client=t&text=”.urlencode($text).”&sl=$from&tl=$to”);
echo substr($result,1,strlen($result)-2);
}
Nel caso l’api non si commentasse da sola ecco la spiegazione dei tre campi:
- $from : codice di lingua di partenza.. (Esempio: en, it, de …)
- $to : codice di lingua di arrivo;
- $text : Il testo da tradurre.
La funzione ritorna, ovviamente, il testo tradotto da google.. Per richieste o malfunzionamenti lasciate un commento .. Saluti 🙂
English Version :
Hello people,
Today, the need for work, I try to find some tools that I facilitate the use of translation service provided by google.
Doing some research I found an API that is not official, unfortunately, is no longer developed (for info Here). Continuing to google that I saw an official released api but has great limitations.
My apis, needs php and is formed by this short function:
function gTranslate($from,$to,$text) {
$result = getPage(“http://translate.google.it/translate_a/t?client=t&text=”.urlencode($text).”&sl=$from&tl=$to”);
echo substr($result,1,strlen($result)-2);
}
If the apis do not comment on its own this is the explanation of the three fields:
- $From code language of departure .. (Example: en, it, de …)
- $To: code of the target language;
- $Text: The text to translate.
The function returns, of course, the text translated by google .. For inquiries or malfunctions leave a comment .. Greetings:)