google-translator-ts
Version:
Free Google Translator API for Node.js
38 lines (27 loc) • 1.2 kB
Markdown






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.
```bash
npm install google-translator-ts
```
```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);
});
```