dictcc
v1.3.0
Published
Unofficial dict.cc translation client
Downloads
5
Maintainers
Readme
dictcc
dictcc
is a client for the dict.cc dictionary service. It
returns a list of translations for a given term for a given source and target
language.
Installation
npm i dictcc
# or
yarn add dictcc
Usage Example
/**
* `translate` translates a `term` from a language (`sourceLanguage`) into another
* language (`targetLanguage`).
*
* `Languages` represents supported languages
*/
import translate, { Languages } from 'dictcc'
const getTranslation = async () => {
const { data, error, url } = await translate({
sourceLanguage: Languages.en,
targetLanguage: Languages.de,
term: 'home',
})
return data
}
A result looks something like this:
[
{
"sourceTranslation": {
"text": "home",
"meta": {
"abbreviations": [],
"comments": ["at home"],
"optionalData": [],
"wordClassDefinitions": ["adv"]
}
},
"targetTranslation": {
"text": "daheim",
"meta": {
"abbreviations": [],
"comments": ["bes. südd., österr. u. schweiz."],
"optionalData": [],
"wordClassDefinitions": []
}
},
"targetTranslationAudioUrl": "https://www.example.com/audio/daheim.mp3"
}
]
License
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!