Google Translator API and many translation for one word

前端 未结 3 991
离开以前
离开以前 2020-12-16 04:51

I am using google-api-translate-java-0.92.jar.


Translate.setHttpReferrer(\"http://translate.g         


        
相关标签:
3条回答
  • 2020-12-16 05:20

    I don't believe you can...

    Looking at the soucre, it builds up the following URL:

    http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=en|uk&q=arrangement

    which when you look at the JSON response, returns:

    {"responseData": {"translatedText":"Композиція"}, "responseDetails": null, "responseStatus": 200}
    

    As you can see, this is only returning a single word. The dictionary lookup on the google translate page must be an additional call to a different service (not part of the translate service)


    EDIT

    Using firebug, you can see the request that is being made by the translate page, and you get this URL:

    http://translate.google.com/translate_a/t?client=t&text=arrangement&hl=en&sl=en&tl=uk&multires=1&otf=2&pc=0&sc=1

    Which returns this:

    [[["Композиція","arrangement","Kompozytsiya"]],[["noun",["розташування","розміщення","домовленість","аранжування","упорядкування","механізм","оформлення","пристрій","систематизація","монтаж","пристосування","урегулювання","плани","згода","залагода","розв'язання","порозуміння"]]],"en"]
    

    However, this extended URL format is not supported by the translate JAR you are using (at least I can't find it in the source on google code), is not part of the googleapis subdomain, and I'm not even sure it's for public consumption or that calling it directly doesn't violate Googles T&Cs.

    But that's how they generate the dictinary list anyway...

    0 讨论(0)
  • 2020-12-16 05:33

    From Google Translate API FAQ (checked: 16 November 2013)

    Is it possible to get multiple translations of a word?

    The answer:

    No. This feature is only available via the web interface at translate.google.com

    source: https://developers.google.com/translate/v2/faq#technical

    0 讨论(0)
  • 2020-12-16 05:37

    There is an open enhancement request for this functionality. So it doesn't look like you're doing anything wrong; the API just doesn't expose that functionality.

    0 讨论(0)
提交回复
热议问题