There already is an auto translate module:
http://drupal.org/project/i18n_auto
This module has the same issue that you mention, which is caused by
Google's compression of the special characters.
Aaron Winborn and I just submitted 4 tasks to the GHOP queue (well,
they're all in one issue, but will be split into 4 tasks) to bring this
module out of Dev and into a full version (part of the task is to fix
this exact issue):
http://drupal.org/node/208539
Care to work with us to fix this module, rather than create a new one?
If this is taken on by one of the students it very well may be fixed in
the near future...
--
Alex Urevick-Ackelsberg
(917) 407-9086
alex@zivtech.com
Future Majority -
http://futuremajority.com
Young Philly Politics -
http://youngphillypolitics.com
ZivTech -
http://zivtech.com
Message:
6
Date: Sat, 12 Jan 2008 19:30:52 +0200
From: "Idan Arbel" <idan@arbel-designs.com>
Subject: [development] Google translation module
To: <
development@drupal.org>
Message-ID: <20080112173054.D6AE530021@sa5.bezeqint.net
>
Content-Type: text/plain; charset="us-ascii"
Hello,
I'm working on a module to auto translate nodes on my websites. I'm
using
google translate to do this.
I've encountered a problem that I was hoping someone would have an idea
how
to solve..when I translate a text that has "special characters", mainly
those that aren't English, and I try to display them, I get characters
that
are black diamonds. When trying to display those using drupal with
drupal
set message, something strange happens, it seems like drupal just
ignores
the entire function. I'm trying to print it out of a nodeapi hook, and
the
when I do all the other drupal_set_messages aren't displayed, even
those
that come before.
Anyway, I think I've isolated the problem to the encoding of the
characters,
but I don't know how to solve it. I see the characters with the black
diamonds when I print_r($translation), in this case I only see them.
And
when ever I try to drupal_set_message them I don't see anything.
If I translate a text that doesn't have one of those characters, all is
well.
This is what I'm using to translate the texts:
function google_translate($text, $from = 'en', $to = 'es') {
$data = "h1=en&ie=UTF8&text=$text";
$result =
drupal_http_request(I18N_AUTO_GOOGLE_TRANSLATE_TRANSLATOR_URL .
'?langpair='. $from .'|'. $to, array(), 'POST', $data);
$texttosearch = "id=result_box";
$start = strpos($result->data, $texttosearch);
$end = strpos($result->data, "</div>", $start+24);
$start = $start + 24;
$translated = substr($result->data, $start, $end-$start);
return $translated;
}
Thanks
Idan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080112/edb9c450/attachment.htm
------------------------------
--
[ Drupal development list | http://lists.drupal.org/ ]
End of development Digest, Vol 61, Issue 32
*******************************************