# translate-google

> A free and unlimited for Google Translate, Multi-translation support object input

Latest version **1.5.0** (published 2021-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install translate-google
pnpm add translate-google
yarn add translate-google
bun add translate-google
```

## 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.5.0 |
| Published | 2021-09-19 |
| First published | 2017-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 23.5 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 25 |
| Author | shikar |
| Maintainers | shikar |
| Keywords | translate, google, translator, free, unlimited, language, batch, multi, object, token |

## Links

- npm: https://www.npmjs.com/package/translate-google
- Repository: https://github.com/shikar/NODE_GOOGLE_TRANSLATE
- Homepage: https://github.com/shikar/NODE_GOOGLE_TRANSLATE#readme
- Issues: https://github.com/shikar/NODE_GOOGLE_TRANSLATE/issues
- npm.io page: https://npm.io/package/translate-google

## Dependencies (8)

- [got](https://npm.io/package/got.md) ^11.8.2
- [is-url](https://npm.io/package/is-url.md) ^1.2.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [safe-eval](https://npm.io/package/safe-eval.md) ^0.4.1
- [num-or-not](https://npm.io/package/num-or-not.md) ^1.0.1
- [configstore](https://npm.io/package/configstore.md) ^6.0.0
- [user-agents](https://npm.io/package/user-agents.md) ^1.0.779
- [is-keyword-js](https://npm.io/package/is-keyword-js.md) ^1.0.3

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.5.0 (latest) — 2021-09-19
- 1.4.3 — 2020-08-10
- 1.4.2 — 2020-07-28
- 1.4.1 — 2020-07-27
- 1.4.0 — 2020-07-16
- 1.3.5 — 2019-01-15
- 1.3.4 — 2019-01-12
- 1.3.3 — 2019-01-10
- 1.3.2 — 2019-01-10
- 1.3.1 — 2019-01-09
- 1.3.0 — 2019-01-09
- 1.2.2 — 2018-12-08
- 1.2.1 — 2018-10-21
- 1.2.0 — 2018-10-15
- 1.1.0 — 2018-08-22
- … 6 more at https://npm.io/package/translate-google/versions

## README

# Translate Google
free google translate

## Change Log
- [changelog.md](https://github.com/shikar/NODE_GOOGLE_TRANSLATE/blob/master/CHANGELOG.md)


## Features

- Auto language detection
- Spelling correction
- Language correction
- Fast and reliable – it uses the same servers that [translate.google.com](https://translate.google.com) uses

## Install
```
npm install --save translate-google
```

## Usage

Perfect support object:

``` js
const translate = require('translate-google')
const tranObj = {
  a: 1,
  b: '1',
  c: "How are you?\nI'm nice.",
  d: [true, 'true', 'hi', { a: 'hello', b: ['world']}],
}

translate(tranObj, {to: 'zh-cn', except:['a']}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})

// => { a: 1, b: '1', c: "你好吗？\n我很好。", d: [true, 'true', '嗨', { a: 'hello', b: ['世界']}] }
```

From automatic language detection to English:

``` js
const translate = require('translate-google')

translate('I speak Chinese', {to: 'zh-cn'}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})
```

From English to Dutch with a typo:

``` js
translate('I speak Chinese!', {from: 'en', to: 'zh-cn'}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})
```


translate for array or object:
``` js
translate({a: 'I speak Chinese!', b: ['hello', 'world']}, {from: 'en', to: 'zh-cn'}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})
```

## API

### translate(text, options)

#### text
Type: `string`, `object`, `array`
The text to be translated

#### options
Type: `object`

##### from
Type: `string` Default: `auto`
The `text` language. Must be `auto` or one of the codes/names (not case sensitive) contained in [languages.js](https://github.com/shikar/NODE_GOOGLE_TRANSLATE/blob/master/languages.js)

##### to
Type: `string` Default: `en`
The language in which the text should be translated. Must be one of the codes/names (not case sensitive) contained in [languages.js](https://github.com/shikar/NODE_GOOGLE_TRANSLATE/blob/master/languages.js).

##### except
Type: `array` Default:`[]`
Attributes in excluded objects do not participate in translation

### Returns an `object`:

- `text` *(string, object, array)* – The translated text.

``` js
translate(['I speak Chinese\nHello world', 'hello'], {from: 'en', to: 'nl'}).then(res => {
    console.log(res);
    //=> ["我说中文\n你好世界","你好"]
}).catch(err => {
    console.error(err);
});
```

## License

MIT © [Shikar](qzh.shi@gmail.com)

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