# Automatic translation of TAGS Twitter archives using Google Apps Script 'Language' services

A flare went up from Hamburg this morning from Tony Hirst who is at the [Daten, Recherchen, Geschichten (2012) conference (#drg12)](http://www.netzwerkrecherche.de/Konferenzen/Fachkonferenzen/Daten-Recherchen-Geschichten-2012/) in Hamburg:

> Anyone know of twitter streaming search clients that run all tweets through language translation?
> 
>  — Tony Hirst (@psychemedia) [March 24, 2012](https://twitter.com/psychemedia/status/183490960028737536)

Translating tweets is something I’ve dabbled with before as part of experiments with my [Twitter Subtitling tool iTitle](http://hawksey.info/ititle/) (really must revisit this). Notable examples were the [Google I/O 2010 Android Keynote](https://hawksey.info/blog/2010/05/google-io-2010-keynote-day-2-android-demo-with-twitter-subtitles/) and presentations from #UIMPUni20 talked about in [Kirsty Pitkin’s Lost In Translation blog post](http://eventamplifier.wordpress.com/2010/09/07/lost-in-translation/) (because of domain shuffles most of the links are broken but here is [Professor Alejandro Piscitelli talk at #UIMPUni20 with tweets normailsed to English](http://hawksey.info/ititle/v/id/EN.14762814/)).

Both these examples used the Google Translate API to convert tweets from one language to another. Back then the API was free for anyone to use but in August 2011 [Google switched it to a paid for service](http://googlecode.blogspot.co.uk/2011/08/paid-version-of-google-translate-api.html) … doh. All is not lost though as Google Apps’ programming environment [Google Apps Script still has a ‘Language Service’](https://developers.google.com/apps-script/class_languageapp) &lt;cough&gt;Google Translate&lt;/cough&gt;. The disadvantage you have with this service is unlike Translate it doesn’t have an option to autodetect the source language. \[Update: Re-read documentation and clearly states it can auto detect. Probably still not a bad idea to use iso codes\] This is not a problem when dealing with Twitter as the metadata includes ‘iso\_language\_code’.

So I have a solution to [archive tweets in a Google Spreadsheet using Google Apps Script](https://hawksey.info/blog/2012/01/twitter-archive-tagsv3/) (must write more about [v4](https://hawksey.info/blog/2012/03/combine-twitter-and-google-analytics-data-to-find-your-top-content-distributors/)) … ponder, ponder, 5 minutes later by adding:

 `objects[i]["text_en"] = LanguageApp.translate(objects[i]["text"], objects[i]["iso_language_code"], "en"); `I’ve got a [spreadsheet archiving #drg12 tweets and translating the text into English](https://docs.google.com/spreadsheet/ccc?key=0AqGkLMU9sHmLdEhIcHZYaV9jaUlYZTI2SGFUNXpUVWc#gid=82). Impressed much?

[![image](https://hawksey.info/wp-content/uploads/2012/03/image13.png "image")](https://docs.google.com/spreadsheet/ccc?key=0AqGkLMU9sHmLdEhIcHZYaV9jaUlYZTI2SGFUNXpUVWc#gid=82)