|
Yes unfortunately it's true
|
|
|
|
|
The article has been updated. Thanks for your help!
/ravi
|
|
|
|
|
Will look into it this weekend.
Thanks,
/ravi
|
|
|
|
|
|
Sweet!
/ravi
|
|
|
|
|
I think i got a pattern here
http://translate.google.com/translate_a/t?client=p&sl=pt&tl=fr&hl=en&sc=2&ie=UTF-8&oe=UTF-8&ssel=0&tsel=0&q=Olá meus amigos, acho que encontrei aqui um padrão. Ora vejamos se é realmente verdade!
Espero que sim!
{
"sentences":
[
{"trans":"Ol? ","orig":"Ol?","translit":"","src_translit":""},
{"trans":"Mes amis, je pense que j'ai trouvé un modèle ici? 'S. ","orig":"meus amigos, acho que encontrei aqui um padr?o.","translit":"","src_translit":""},
{"trans":"Avouons-le? ","orig":"Ora vejamos se ?","translit":"","src_translit":""},
{"trans":"vrai! l'espère!","orig":"realmente verdade!Espero que sim!","translit":"","src_translit":""}
],
"src":"pt","spell":{"spell_html_res":"\u003cb\u003e\u003ci\u003eOlá\u003c/i\u003e\u003c/b\u003e? meus amigos, acho que encontrei aqui um padr?o. Ora vejamos se ? realmente verdade!Espero que sim!","spell_res":"Olá? meus amigos, acho que encontrei aqui um padr?o. Ora vejamos se ? realmente verdade!Espero que sim!","correction_type":[1]},
"server_time":60
}
|
|
|
|
|
Yes, Google Translate translates a paragraph of text as individual translations. It's nice to have JSON API at our disposal! I'll plan to update the article over the weekend.
/ravi
|
|
|
|
|
I think now we also have translated dictionary / synonyms list for single words Amazing, this is even better!!
http://translate.google.com/translate_a/t?client=p&sl=auto&tl=en&hl=en&sc=2&ie=UTF-8&oe=UTF-8&ssel=0&tsel=0&q=Resumo%0d
{
"sentences":
[
{"trans":"Abstract","orig":"Resumo","translit":"","src_translit":""}
],
"dict":
[
{"pos":"noun","terms":
[
"summary","abstract","resume","brief","digest","synopsis","epitome","excerpt","abridgment","extract","abridgement","compendium","precis","syllabus","condensation","docket","playbill"
],
"entry":
[
{"word":"summary","reverse_translation":["resumo","sumário","síntese","epítome"],"score" .38553435},
{"word":"abstract","reverse_translation":["resumo","abstrato","sumário","abstração","extrato"],"synset_id":[56872],"score" .29101658},
{"word":"resume","reverse_translation":["resumo","sumário","comprimido","pastilha"],"score" .020115795},
{"word":"brief","reverse_translation":["resumo","sumário","depoimento","causa"],"score" .011642128},
{"word":"digest","reverse_translation":["resumo","sumário","compilação","digesto","resenha","condensação"],"score" .0029899459},
{"word":"synopsis","reverse_translation":["sinopse","resumo","sumário","epítome"],"synset_id":[56872],"score" .0015755907},
{"word":"epitome","reverse_translation":["epítome","resumo"],"score" .00060744432},
{"word":"excerpt","reverse_translation":["excerto","extrato","resumo"],"synset_id":[55304],"score" .00050358905},
{"word":"abridgment","reverse_translation":["resumo","abreviação","diminuição","simplificação"],"synset_id":[58120],"score" .00050358905},
{"word":"extract","reverse_translation":["extrato","resumo","essência"],"synset_id":[55304],"score" .00036843363},
{"word":"abridgement","reverse_translation":["simplificação","resumo","abreviação","diminuição"],"synset_id":[58120],"score" .00017133754},
{"word":"compendium","reverse_translation":["compêndio","resumo","sumário"],"score":9.0288544e-05},
{"word":"precis","reverse_translation":["resumo","sumário","epítome"],"synset_id":[56872],"score":8.4818232e-05},
{"word":"syllabus","reverse_translation":["programa de estudos","sumário","resumo","sílabo"],"score":8.2208651e-05},
{"word":"condensation","reverse_translation":["condensação","resumo","abreviação"],"synset_id":[58120],"score":6.2054343e-05},
{"word":"docket","reverse_translation":["súmula","resumo","sumário","recibo","rótulo","etiqueta"],"score":5.2255e-05},
{"word":"playbill","reverse_translation":["cartaz","anúncio","sílabo","programa de estudos","resumo","sumário"],"score":2.9023204e-06}
],
"base_form":"resumo","pos_enum":1}
],
"src":"pt","server_time":10}
modified 8-Mar-14 2:31am.
|
|
|
|
|
After get response from the stream use this to collect the translation it seams to work reasonably
Have a nice weekend!
...
Stream stream = resp.GetResponseStream();
StreamReader streamReader = new StreamReader(stream);
string m_strContent = streamReader.ReadToEnd();
m_strContent = ExtractString(m_strContent, @"{""sentences"":[", "]");
string[] entrys = Regex.Split(m_strContent, @"{""trans"":""");
m_strContent = "";
foreach (string entr in entrys)
{
if (entr != "")
{
try
{
m_strContent += entr.Substring(0, entr.IndexOf
(@""",""orig"":"""));
}
catch
{
}
}
}
...
public static string ExtractString(string strText, string strx1, string strx2)
{
if (strText == "") return "";
int i = strText.IndexOf(strx1);
if (i == -1) return "";
i += strx1.Length;
int w = strText.IndexOf(strx2, i);
if (w == -1) return "";
return strText.Substring(i, w - i);
}
|
|
|
|
|
The article has been updated. Thanks for your help!
/ravi
|
|
|
|
|
|
|
how can i avoid google block if I use this coding in a huge way..!!
|
|
|
|
|
Member 10551326 wrote: how can i avoid google block The best you could do is pause one or more seconds (randomly) between requests to prevent your IP from being blocked.
/ravi
|
|
|
|
|
|
But why not using the c# API ?
|
|
|
|
|
Do you mean the C# binding to the official Google Translate API? I believe that API was dicontinued in 2011 and the paid version ceased operation in 2012.
/ravi
|
|
|
|
|
|
hi.thanks for this code.
i have question.i have to use bingtranslator instead of google and only change the url statement.but it has error as length and index.
i'm beginner and interested in programming.please help me.
|
|
|
|
|
Simply changing the URL isn't enough. You need to parse the data returned by Bing in order to process the result. See this article for details: WebResourceProvider goes .NET[^] .
/ravi
|
|
|
|
|
After struckling a few days for a translator solution for my app, I came across Ravi's article - within a hour I had a working solution. Thank you Ravi
But being a Dane I have to deal with our special characters, they are not being translated
modified 18-Sep-13 3:16am.
|
|
|
|
|
Thanks for your comment. Will look into it shortly.
/ravi
|
|
|
|
|
Hi Ravi,
very good job.
I have only one question.
Is there the possibility that Google check their pages against automatic reading by a software like yours?
I am interested to use it in a massive way.
|
|
|
|
|
armax75 wrote: I am interested to use it in a massive way. Don't. Your IP address will likely be blocked as the source of a suspected DOS attack.
/ravi
|
|
|
|
|
Very nice..
Here's one I published Language Translator using Google Translate
An inspiration from your article. The only reason I had to implement such is to achieve code re-usability for Phones, Desktops etc.
Thanks,
|
|
|
|
|