UNPKG

google-translator-ts

Version:

Free Google Translator API for Node.js

38 lines (27 loc) 1.2 kB
# google-translator-ts ![dt](https://img.shields.io/npm/dt/google-translator-ts.svg?style=for-the-badge) ![l](https://img.shields.io/npm/l/google-translator-ts.svg?style=for-the-badge) ![min](https://img.shields.io/bundlephobia/min/google-translator-ts.svg?style=for-the-badge) ![types](https://img.shields.io/npm/types/google-translator-ts.svg?style=for-the-badge) ![v](https://img.shields.io/npm/v/google-translator-ts.svg?style=for-the-badge) ![npm](https://nodei.co/npm/google-translator-ts.png?downloadRank=true&downloads=true) ## Introduction This is a simple and easy to use package for translating text using Google Translate for `Free`. It is a TypeScript package and can be used in both TypeScript and JavaScript projects. ## Installation ```bash npm install google-translator-ts ``` ## Usage ```javascript import { translator } from "google-translator-ts"; const source = "en"; // "" or "auto" for auto-detection const target = "es"; const text = "Hello, how are you?"; translator(source, target, text) .then((translation) => { console.log("translation:", translation); }) .catch((error) => { console.error("error:", error); }); ```