The failure to preserve newlines is a result of the API assuming it's dealing with HTML, which does not require newlines. If you want to preserve them, you can specify format=text, but that will result in the API attempting to translate any HTML markup that you have in the string. Alternatively, you could replace any newlines with some HTML tag that you will then replace with newlines after the translation is returned.
Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com [email protected] If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! On Sep 9, 2010, at 3:17 AM, egasimus wrote: > Hi everyone. As a part of some automation stuff I'm working on in > order to make my life easier, I'm trying to translate a block of text > using, well, a lot of stuff. AutoIt3, Firefox, MozRepl, JavaScript, > and, ultimately, Google Translate API. What it all boils down to is a > page containing a single textarea and button, which POSTs my source > text to, for example, > http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=en%7Cru. > > So the button gets clicked, the text get sent, and the browser goes to > that URL and shows the text representation of a responseData object. > This text gets read through JS, stripped, and made use of. However, in > the translatedText field, all the newlines from the source text are > gone without a trace, and this bothers me greatly, as I'd rather keep > them. Any ideas how to preserve newlines when using the API? > > -- > You received this message because you are subscribed to the Google Groups > "Google AJAX APIs" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-ajax-search-api?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-ajax-search-api?hl=en.
