3

I am interested in translating English words to a specific language (e.g. Russian). I have read the whole Wiktionary API manual but I have not found a good way. For the word “dog” I can obtain the whole section that contains translations to other languages, by using the wiktionary API in the following way:

http://en.wiktionary.org/w/api.php?action=query&titles=dog&prop=revisions&rvprop=content&rvsection=11

The translations section number is not constant and it is different for various words. For “dog” the translation section number is 11 but for “cat” I need rvsection=7. Is it possible to obtain a translation to a specific language for any English word without downloading the whole translation section?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Krzysztof
  • 31
  • 1
  • 2

4 Answers4

6

You can get quite a lot of the translations by requesting the interwiki links from the API. I have written a simple JS app using this approach: http://jsfiddle.net/karlb/PxfrJ/11/ .

Karl Bartel
  • 3,244
  • 1
  • 29
  • 28
2

The dbpedia and Dbnary projects extract translation data from Wiktionary as RDF and provide a SPARQL endpoint where you can query translations without needing to download large data sets.

Here's a query example for Dbnary:

SELECT DISTINCT ?written_trans AS ?translations
WHERE {
    ?lexentry ontolex:canonicalForm [
        ontolex:writtenRep "dog"@en
    ] .

    ?trans dbnary:isTranslationOf ?lexentry ;
           dbnary:targetLanguage lexvo:rus ;
           dbnary:writtenForm ?written_trans .
}

Which leads to these results.

Karl Bartel
  • 3,244
  • 1
  • 29
  • 28
2

You can use this to help translate "dog" from English to Russian. This URL finds the internal links that start with "ru" for pages with the title "dog" : https://en.wiktionary.org/w/api.php?action=query&prop=iwlinks&titles=dog&iwprop=url&iwprefix=ru&format=json&continue=

I emphasize help because you will get many ambiguous translations which you might want to disambiguate using categories and other things.

That URL has "iwprop=url" so you can easily click the links but in your application I suggest you use this: https://en.wiktionary.org/w/api.php?action=query&prop=iwlinks&titles=dog&iwprefix=ru&format=json&continue= and make the links yourself.

Justin Harris
  • 1,969
  • 2
  • 23
  • 33
1

The Wiktionary API won't do specific translations of one word between two languages. It's not possible to do what you are wanting to do here.

However, Google Translate does have an API that can do what you're looking for.

Sam Starling
  • 5,298
  • 3
  • 35
  • 52
  • 1
    Yes Wiktionary doesn't have an API of its own. Wiktionary basically refers to the content of one site which is running on the MediaWiki software and the API is part of MediaWiki. The API thus knows stuff about wiki sites but knows nothing about dictionaries )-: – hippietrail Aug 26 '11 at 08:36
  • Updated my answer with a link to the Google Translate API, which seems to do what you need. – Sam Starling Aug 26 '11 at 09:09