# tiny-translator

> Tiny translation library for Azure Translator Text service

Latest version **1.2.2** (published 2019-04-27) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install tiny-translator
pnpm add tiny-translator
yarn add tiny-translator
bun add tiny-translator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2019-04-27 |
| First published | 2019-02-13 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jason Mulligan |
| Maintainers | avoidwork |
| Keywords | azure, text, translator, translation |

## Links

- npm: https://www.npmjs.com/package/tiny-translator
- Repository: https://github.com/avoidwork/tiny-translator
- Homepage: https://github.com/avoidwork/tiny-translator#readme
- Issues: https://github.com/avoidwork/tiny-translator/issues
- npm.io page: https://npm.io/package/tiny-translator

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.4.1

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2019-04-27
- 1.2.1 — 2019-04-27
- 1.2.0 — 2019-04-27
- 1.1.0 — 2019-04-26
- 1.0.4 — 2019-02-13
- 1.0.3 — 2019-02-13
- 1.0.2 — 2019-02-13
- 1.0.1 — 2019-02-13
- 1.0.0 — 2019-02-13

## README

# Tiny Translator
Tiny translation library for Azure Translator Text service.

[![build status](https://secure.travis-ci.org/avoidwork/tiny-translator.svg)](http://travis-ci.org/avoidwork/tiny-translator)

### Example
```javascript
const translator = require("tiny-translator")("SUBSCRIPTION_KEY");

async function translate (arg, to = "zh-Hans") {
  let result;
  
  try {
    const data = await translator.translate({text: arg, to: to});
    
    result = data.text;
  } catch (e) {
    console.error(e.message);
  }

  return result;
}

(async function () {
  const translated = await translate("Hello, what is your name?");

  console.log(translated); // "你好, 你叫什么名字？"
}());
```

### API
#### factory (subscriptionKey)
Returns an instance of Tiny Translator.

#### languages (scope=translation,transliteration,dictionary)
Asynchronous function which returns a list of supported languages per scope.

#### reset ()
Resets the translator token to empty string.

#### translate ({text: '' || [{Text: '', ...], to: 'lang'[, from: 'lang', textType: 'plain' || 'html', category: 'general', profanityAction: 'NoAction' || 'Marked' || 'Deleted', profanityMarker: 'Asterisk' || 'Tag', includeAlignment: true || false, includeSentenceLength: true || false, suggestedFrom: 'lang', fromScript: 'x', toScript: 'y', allowFallback: true || false]})
Asynchronous function which returns a translation. 

## License
Copyright (c) 2019 Jason Mulligan
Licensed under the BSD-3 license.

---
_Source: https://npm.io/package/tiny-translator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
