text: #!/usr/bin/env python
  
  # get-strings.py
  # By Michael Geary - http://mg.to/
  # See UNLICENSE or http://unlicense.org/ for public domain notice.
  
  # Reads the JSON feed for a Google Docs spreadsheet containing the
  # localized strings for the Google Election Center gadget, then writes
  # the strings for each language into a JSONP file for that language.
  # The JSONP output has line breaks and alphabetized keys for better
  # version control, e.g.:
  #
  # loadStrings({
  # "areYouRegistered": "Are you registered to vote?", 
  # "dateFormat": "{{monthName}} {{dayOfMonth}}", 
  # "yourHome": "Your Home", 
  # "yourVotingLocation": "Your Voting Location"
  # })
  
  import json, re, urllib2
  
  url = 'https://spreadsheets.google.com/feeds/list/0AuiC0EUz_p_xdHE3R2U5cTE0aFdHcWpTVVhPQVlzUmc/1/public/values?alt=json'
  
  langs = {}
  
  feed = json.load( urllib2.urlopen(url) )['feed']
  
  for entry in feed['entry']:
  	id = entry['gsx$id']['$t']
  	for col in entry:
  		match = re.match( 'gsx\$text-(\w+)$', col )
  		if match:
  			lang = match.group( 1 )
  			if lang not in langs: langs[lang] = {}
  			langs[lang][id] = entry[col]['$t']
  
  for lang in langs:
  	j = json.dumps( langs[lang], indent=0, sort_keys=True )
  	file = 'lang-%s.js' % lang
  	print 'Writing ' + file
  	open( file, 'wb' ).write( 'loadStrings(%s)' % j )
  