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?
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/ .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With