Skip to content

Commit

Permalink
minor changes, added logging of translation calls, broke out steps in…
Browse files Browse the repository at this point in the history
… api call
  • Loading branch information
Tim Burks committed Sep 28, 2010
1 parent c3504c7 commit 9c56bcd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions service/site/google.nu
@@ -1,5 +1,7 @@

(function google-translate (source destination phrase)
(NSLog (+ "translating " phrase " from " source " to " destination))

(set REFERER "http://www.radtastical.com")
(set SERVICE "http://ajax.googleapis.com/ajax/services/language/translate")
(set args (dict v:"1.0"
Expand All @@ -12,8 +14,9 @@
;; but I don't see how to do this with the API we use below
(set path (+ SERVICE "?" (args urlQueryString)))
(set url (NSURL URLWithString:path))
(set response ((NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil) JSONValue))

(set responseData (NSData dataWithContentsOfURL:url))
(set responseString ((NSString alloc) initWithData:responseData encoding:NSUTF8StringEncoding))
(set response (responseString JSONValue))

(if (eq (response responseStatus:) 200)
(then (((response responseData:) translatedText:) stringByDecodingXMLEntities))
Expand Down

0 comments on commit 9c56bcd

Please sign in to comment.