<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: Translate text in C#, using Google Translate</title>
	<atom:link href="http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate/feed" rel="self" type="application/rss+xml" />
	<link>http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
	<description></description>
	<lastBuildDate>Wed, 10 Mar 2010 13:52:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Martin H. Normark</title>
		<link>http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate/comment-page-1#comment-437</link>
		<dc:creator>Martin H. Normark</dc:creator>
		<pubDate>Wed, 10 Mar 2010 13:52:09 +0000</pubDate>
		<guid isPermaLink="false">/post/Translate-text-in-C-using-Google-Translate.aspx#comment-437</guid>
		<description>Hi Bob

Take a look at the comment above yours. Lennart points out, that Google may have changed their HTML markup lately - which have broken my code.

Hope you&#039;ll get it working.</description>
		<content:encoded><![CDATA[<p>Hi Bob</p>
<p>Take a look at the comment above yours. Lennart points out, that Google may have changed their HTML markup lately &#8211; which have broken my code.</p>
<p>Hope you&#8217;ll get it working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bob</title>
		<link>http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate/comment-page-1#comment-436</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Tue, 09 Mar 2010 14:48:21 +0000</pubDate>
		<guid isPermaLink="false">/post/Translate-text-in-C-using-Google-Translate.aspx#comment-436</guid>
		<description>I am trying to user this code in c# 2008 express on Window XP.
I have modified the line below
//Match m = Regex.Match(result, &quot;(?&lt;=&lt;div id=result_box dir=\&quot;ltr\&quot;&gt;)(.*?)(?=&lt;/&gt;)&quot;); 
to 
Match m =   Regex.Match(result, &quot;(?&lt;=overflow:auto\&quot;&gt;)(.*?)(?&lt;=&lt;/textarea&gt;)&quot;);
This is returning the text but the translation pair is not working as I expected. If I pass in &quot;HELLO MY FRIEND&quot; &quot;en&#124;sp&quot; the result is &quot;HELLO MY FRIEND&lt;/textarea&gt;&quot;. If I pass in &quot;HOLA MI AMIGO&quot; &quot;sp&#124;en&quot; I get &quot;HELLO MY FRIEND&lt;/textarea&gt;&quot;.
If I passin &quot;HELLO MY FRIEND&quot; &quot;en&#124;da&quot; the result is &quot;Hello my friend&lt;/textarea&gt;&quot;. A different font proper case but no translation. Can you throw any lighy on this problem?
Thanks in advance
Bob pointon




Hello my friend&lt;/textarea&gt;

</description>
		<content:encoded><![CDATA[<p>I am trying to user this code in c# 2008 express on Window XP.<br />
I have modified the line below<br />
//Match m = Regex.Match(result, &quot;(?&lt;=&lt;div id=result_box dir=\&quot;ltr\&quot;&gt;)(.*?)(?=&lt;/&gt;)&quot;);<br />
to<br />
Match m =   Regex.Match(result, &quot;(?&lt;=overflow:auto\&quot;&gt;)(.*?)(?&lt;=&lt;/textarea&gt;)&quot;);<br />
This is returning the text but the translation pair is not working as I expected. If I pass in &quot;HELLO MY FRIEND&quot; &quot;en|sp&quot; the result is &quot;HELLO MY FRIEND&lt;/textarea&gt;&quot;. If I pass in &quot;HOLA MI AMIGO&quot; &quot;sp|en&quot; I get &quot;HELLO MY FRIEND&lt;/textarea&gt;&quot;.<br />
If I passin &quot;HELLO MY FRIEND&quot; &quot;en|da&quot; the result is &quot;Hello my friend&lt;/textarea&gt;&quot;. A different font proper case but no translation. Can you throw any lighy on this problem?<br />
Thanks in advance<br />
Bob pointon</p>
<p>Hello my friend&lt;/textarea&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lennart &#216;ster</title>
		<link>http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate/comment-page-1#comment-435</link>
		<dc:creator>Lennart &#216;ster</dc:creator>
		<pubDate>Sun, 10 Jan 2010 09:47:05 +0000</pubDate>
		<guid isPermaLink="false">/post/Translate-text-in-C-using-Google-Translate.aspx#comment-435</guid>
		<description>It seems that google has changed its layout of the result page. I choce to use the HtmlAgilityPack, which makes it much easier to handle those changes.

        public static string Translate(string input, string languagePair, Encoding encoding)
        {
            string url = String.Format(&quot;http://www.google.com/translate_t?hl=en&amp;ie=UTF8&amp;text={0}&amp;langpair={1}&quot;, input, languagePair);

            string result = String.Empty;

            using (WebClient webClient = new WebClient())
            {
                webClient.Encoding = encoding;
                result = webClient.DownloadString(url);
            }

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(result);
            return doc.DocumentNode.SelectSingleNode(&quot;//textarea[@name=&#039;utrans&#039;]&quot;).InnerText;
        }

Get the HtmlAgilityPack here: http://www.codeplex.com/htmlagilitypack

I hope this will help the translation to keep working for everyone</description>
		<content:encoded><![CDATA[<p>It seems that google has changed its layout of the result page. I choce to use the HtmlAgilityPack, which makes it much easier to handle those changes.</p>
<p>        public static string Translate(string input, string languagePair, Encoding encoding)<br />
        {<br />
            string url = String.Format(&quot;http://www.google.com/translate_t?hl=en&amp;ie=UTF8&amp;text={0}&amp;langpair={1}&quot;, input, languagePair);</p>
<p>            string result = String.Empty;</p>
<p>            using (WebClient webClient = new WebClient())<br />
            {<br />
                webClient.Encoding = encoding;<br />
                result = webClient.DownloadString(url);<br />
            }</p>
<p>            HtmlDocument doc = new HtmlDocument();<br />
            doc.LoadHtml(result);<br />
            return doc.DocumentNode.SelectSingleNode(&quot;//textarea[@name='utrans']&quot;).InnerText;<br />
        }</p>
<p>Get the HtmlAgilityPack here: <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow">http://www.codeplex.com/htmlagilitypack</a></p>
<p>I hope this will help the translation to keep working for everyone</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daxii</title>
		<link>http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate/comment-page-1#comment-434</link>
		<dc:creator>Daxii</dc:creator>
		<pubDate>Mon, 07 Sep 2009 10:06:55 +0000</pubDate>
		<guid isPermaLink="false">/post/Translate-text-in-C-using-Google-Translate.aspx#comment-434</guid>
		<description>How to translate a formatted html text, like the google translate when you type a full url?</description>
		<content:encoded><![CDATA[<p>How to translate a formatted html text, like the google translate when you type a full url?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin H. Normark</title>
		<link>http://martinnormark.com/2009/03/12/translate-text-in-c-using-google-translate/comment-page-1#comment-433</link>
		<dc:creator>Martin H. Normark</dc:creator>
		<pubDate>Mon, 11 May 2009 20:40:23 +0000</pubDate>
		<guid isPermaLink="false">/post/Translate-text-in-C-using-Google-Translate.aspx#comment-433</guid>
		<description>Have you tried to pass in &quot;en&#124;ar&quot; as the languagePair?</description>
		<content:encoded><![CDATA[<p>Have you tried to pass in &quot;en|ar&quot; as the languagePair?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
