Closed gbelot2003 closed 4 years ago
Ok, if anyone comes to a problem like this, for me, html_entity_decode() solve the problem!!
could you provide some more details regarding your fix ?
Sorry for the delay, is very simple indid, in the controller, the string about to be translated, it has to be sanitize first, remember, now is a get verb. I just create a simple function before translation. and of course, all the code about in my first entry is unnecesary, you just have clear the strings to pass for translations
private function cleanText($string)
{
return trim(html_entity_decode($string, ENT_COMPAT, 'UTF-8'));
}
then just
$factor = $this->cleanText($muestra->body); $body = $translator->setSource('es') ->setTarget('en') ->translate($factor);
But I still got that error. I added the function cleanText() before using it in translate()
@gbelot2003 I've tried figuring out what was the original text you wanted to translate, and by decoding the url you pasted I found that it could have been the following:
DESCRIPCIÓN MACROSCÓPICA: Se recibe 1 frasco conteniendo 2 láminas con frotis fijados con alcohol de región sangrado pezón derecho, se colorean con hematoxilina-eosina. DIAGNÓSTICO: PEZON DERECHO, ASPIRADO AGUJA FINA, EXTENDIDOS - COMENTARIO:
I see that you also figured out that HTML entities caused the problem because you solved it using html_entity_decode(). But what's really interesting, if I copy&paste the text above to the official Google Translate page, I also get a translation error on that page (which I never ever saw before). See:
It looks like this is an error with Google Translate itself, and I verified this as Google Translate fails even on a simple string if it contains any HTML entity like Hello world!
.
If anybody expects to translate strings containing HTML entities I suggest them to decode the strings with html_entity_decode() before passing them to the translate function, until Google fixes this issue.
@Stichoza Until then I also suggest that this should be noted in the known limitations.
Hello there. Just now I update the translate v3.4 module according with the changes you suggested, and for simple text works fine, but now the API uses the verb GET but the main problem is that I am using a text field with html, the answer is always: resulted in a
403 Forbidden
response: Im already using something like this to clear the code:even after all this cleanning Im still getting this response from the server:
Client error:
GET https://translate.google.com/translate_a/single?client=webapp&hl=en&dt=t&sl=es&tl=en&q=DESCRIPCI%26Oacute%3BN+MACROSC%26Oacute%3BPICA%3A++%26nbsp%3B++Se+recibe+1+frasco+conteniendo+2+l%26aacute%3Bminas+con+frotis+fijados+con+alcohol+de+regi%26oacute%3Bn+sangrado+pez%26oacute%3Bn+derecho%2C+se+colorean+con+hematoxilina-eosina.++++DIAGN%26Oacute%3BSTICO%3A+PEZON+DERECHO%2C+ASPIRADO+AGUJA+FINA%2C+EXTENDIDOS+-+++%26nbsp%3B++COMENTARIO%3A&ie=UTF-8&oe=UTF-8&multires=1&otf=0&pc=1&trs=1&ssel=0&tsel=0&kc=1&tk=531074.928252
resulted in a403 Forbidden
response:My cuestion, is there a workaround, option or maybe another module to fix this issue,
thanks