dictcc
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

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):

Stefan Natter
Stefan Natter

🤔 💻
Juan Rodriguez
Juan Rodriguez

💻

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

Package Sidebar

Install

npm i dictcc

Weekly Downloads

2

Version

1.3.0

License

MIT

Unpacked Size

27.5 kB

Total Files

27

Last publish

Collaborators

  • natterstefan