<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Software and Opinions &#187; greasemonkey</title>
	<atom:link href="http://ianloic.com/tag/greasemonkey/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianloic.com</link>
	<description>from Ian McKellar</description>
	<lastBuildDate>Thu, 19 Nov 2009 22:05:43 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Twitter Translation</title>
		<link>http://ianloic.com/2008/04/22/twitter-translation/</link>
		<comments>http://ianloic.com/2008/04/22/twitter-translation/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 05:37:48 +0000</pubDate>
		<dc:creator>Ian McKellar</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[translation]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[userscript]]></category>

		<guid isPermaLink="false">http://ianloic.com/?p=52</guid>
		<description><![CDATA[My friend Britt mentioned today that he was about to launch twitter.jp. How exciting! But I don&#8217;t understand Japanese. If only I could easily translate all those tweets in languages I don&#8217;t understand.
I played around with Google&#8217;s new AJAX Translation API before and I wondered how hard it would be to use that from a [...]]]></description>
			<content:encoded><![CDATA[<p>My friend <a href="http://twitter.com/bs">Britt</a> mentioned today that he was about to launch <a href="http://twitter.jp/">twitter.jp</a>. How exciting! But I don&#8217;t understand Japanese. If only I could easily translate all those tweets in languages I don&#8217;t understand.</p>
<p>I played around with Google&#8217;s new <a href="http://code.google.com/apis/ajaxlanguage/">AJAX Translation API</a> <a href="http://ianloic.com/2008/03/20/google-ajax-apis-outside-the-browser/">before</a> and I wondered how hard it would be to use that from a <a href="http://www.greasespot.net/">GreaseMonkey</a> script. The answer: hard. I&#8217;m not sure what the exact problem was but every way I tried to include Google&#8217;s APIs into the pages I was manipulating, including creating my own <code>iframe</code> and using <code>document.write</code> failed. In the end I used a static proxy html file (hosted in one of my Amazon S3 buckets for cheap efficiency) with some sneaky cross-site communication (the request goes over in location.hash, the response comes back in window.name).</p>
<p>My script is now up on userscripts.org: <a href="http://userscripts.org/scripts/show/25508">twitlator.user.js</a></p>
<p>To use it simply go to a page listing a bunch of tweets, like the <a href="http://twitter.com/public_timeline">public timeline</a> and find a tweet in a language you don&#8217;t under stand. For example:</p>
<p><img class="alignnone size-full wp-image-53" title="A tweet" src="http://ianloic.com/wp-content/uploads/2008/04/twitlator-1.png" alt="" /></p>
<p>Click the <strong>translate!</strong> link and several moments later you&#8217;ve got:</p>
<p><img class="alignnone size-full wp-image-54" title="A translated tweet" src="http://ianloic.com/wp-content/uploads/2008/04/twitlator-2.png" alt="" /></p>
<p>Yep. People aren&#8217;t posting anything interesting in Japanese either.</p>
<p>I&#8217;m pretty sure my script will only work on <a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 3</a>. I&#8217;m using <code>getElementsByClassName</code> which I think wasn&#8217;t introduced until Firefox 3. Why aren&#8217;t you running it already?</p>
]]></content:encoded>
			<wfw:commentRss>http://ianloic.com/2008/04/22/twitter-translation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
