With Yahoo’s babel fish translate webservice gone and Google’s translate service requiring payment there leaves only one free translate API around. Bing Translate. It’s not the easiest API to interface with, but using YQL and the execute block makes it easy. Bing Translate generously gives you 2 million characters a month – for free. Any thing more then that will cost you. (*I will add this table to github.com/yql shortly)
<?xml version="1.0" encoding="UTF-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta> <author>Paul Donnelly (@pjdonnelly)</author> <description>Get your Bing translate keys here: https://datamarket.azure.com/developer/applications/</description> <documentationURL>http://msdn.microsoft.com/en-us/library/ff512421</documentationURL> <sampleQuery>select * from {table} where text="hello world" and client_id="" and client_secret=""</sampleQuery> </meta> <bindings> <select itemPath="" produces="XML"> <urls> <url></url> </urls> <inputs> <key id="text" type="xs:string" paramType="query" required="true" /> <key id="from" type="xs:string" paramType="query" default="en" /> <key id="to" type="xs:string" paramType="query" default="es" /> <key id="client_id" type="xs:string" paramType="query" required="true" /> <key id="client_secret" type="xs:string" paramType="query" required="true" /> <key id="scope" type="xs:string" paramType="query" default="http://api.microsofttranslator.com" /> <key id="grant_type" type="xs:string" paramType="query" default="client_credentials" /> </inputs> <execute> <![CDATA[ var params = "client_id="+client_id+"&client_secret="+client_secret+"&scope="+scope+"&grant_type="+grant_type; y.log(params); var resp = y.rest("https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/").accept('application/json').contentType("application/x-www-form-urlencoded").post(params).response; var MSTranslate = y.rest("http://api.microsofttranslator.com/v2/Http.svc/Translate?text="+text+"&from="+from+"&to="+to).header("Authorization","Bearer " +resp.access_token).get().response; response.object = MSTranslate; ]]> </execute> </select> </bindings> </table>
2 Comments
good table:) translating services online are very poor in terms of development access. That is interesting.
!!ITS GOOD!!
what’s name of the {table} to use it?