1.3.0 • Published 1 year ago

dictcc v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

dictcc

npm version Node CI GitHub issues GitHub license PRs Welcome

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

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!