# open-google-translator

> A versatile and easy-to-use NPM package that leverages the power of the Google Translator API

Latest version **1.0.5** (published 2024-07-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install open-google-translator
pnpm add open-google-translator
yarn add open-google-translator
bun add open-google-translator
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-07-26 |
| First published | 2023-11-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | vidya-hub, jasthilokesh |
| Keywords | translator, google-translator, free-google-translator, open-google-translator, translate |

## Links

- npm: https://www.npmjs.com/package/open-google-translator
- Repository: https://github.com/vidya-hub/open-google-translator
- Homepage: https://github.com/vidya-hub/open-google-translator#readme
- Issues: https://github.com/vidya-hub/open-google-translator/issues
- npm.io page: https://npm.io/package/open-google-translator

## 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.0.5 (latest) — 2024-07-26
- 1.0.4 — 2023-12-04
- 1.0.3 — 2023-11-28
- 1.0.2 — 2023-11-27
- 1.0.1 — 2023-11-27
- 1.0.0 — 2023-11-27

## README

# open-google-translator

![npm version](https://img.shields.io/npm/v/open-google-translator.svg) ![license](https://img.shields.io/npm/l/open-google-translator.svg)

A versatile and easy-to-use NPM package that leverages the power of the Google Translator API. With support for 104 languages, this package can seamlessly translate text in both web and Node.js environments.

## Installation

```bash
npm install open-google-translator
```

## Usage

### Node.js

```javascript
const translator = require("open-google-translator");

translator.supportedLanguages();

translator
  .TranslateLanguageData({
    listOfWordsToTranslate: ["hello here i am", "HI hello"],
    fromLanguage: "en",
    toLanguage: "hi",
  })
  .then((data) => {
    console.log(data);
  });
```

- `translator.supportedLanguages();` this method will provide pair of language iso639-1 language codes with respective language original names

  Example:

  ```json
  {
    af: "Afrikaans",
    sq: "Albanian",
    am: "Amharic",
    ar: "Arabic",
    hy: "Armenian",
    az: "Azerbaijani",
    eu: "Basque",......
  }
  ```

### Browser

1. Include the script in your HTML file:

```html
<script src="https://cdn.statically.io/gh/vidya-hub/open-google-translator/main/dist/bundle.js"></script>
```

2. Access the package methods using the `openGoogleTranslator` variable:

```javascript
openGoogleTranslator
  .TranslateLanguageData({
    listOfWordsToTranslate: ["hello here i am", "HI hello"],
    fromLanguage: "en",
    toLanguage: "te",
  })
  .then((data) => {
    console.log(data);
  });
```

## Inputs

- `listOfWordsToTranslate`: An array of sentences to be translated.
- `fromLanguage`: The language code of the original text (e.g., "en" for English).
- `toLanguage`: The language code of the target translation (e.g., "hi" for HIndi).

## Output

The output consists of an array of objects, each containing the original and translated sentences.

```js
[
  { original: "hello here i am", translation: "नमस्ते मैं यहाँ हूँ" },
  { original: "HI hello", translation: "हाय हैलो" },
];
```

## Features

- Supports translation for 104 languages.
- Works seamlessly in both Node.js and browser environments.
- Simple and intuitive API for easy integration.
- Fast and efficient unlimited translation using the free Google Translator API.

## Contributing

If you find any issues or have suggestions for improvement, feel free to open an [issue](https://github.com/vidya-hub/open-google-translator/issues) or submit a [pull request](https://github.com/vidya-hub/open-google-translator/pulls).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Disclaimer 📝

Please be aware that this package is created exclusively for educational purposes. The token generation method employed in this package is based on the one utilized by https://translate.googleapis.com. It is important to note that for other types of usage (COMMERCIAL or PRODUCTION use), acquiring the official [Google Translator API](https://cloud.google.com/translate/) is recommended.

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