google-translate-api-wrapper

1.0.4 • Public • Published

Google Translate Api Wrapper

Convert text to different languages on the browser. Flexible package and powerful back-end using Google :

Getting started

This package can be used in on the browser. For the browser we are using fetch, so you might want to polyfill it depending on the browsers you support.

Install:

npm install google-translate-api-wrapper

Then import it to use it:

import {translate, detect} from 'google-translate-api-wrapper'

To use it in the browser download the main translate.min.js file and include it:

<script src="google-translate.js"></script>

Options

The first parameter is the string that you want to translate. Right now only a single string of text is accepted.

The second parameter is the options. It accepts either a String of the language to translate to or a simple Object with these options:

Examples:

// Translate from Indonesia  to English
const foo = await translate('Nasi goreng', { to: 'en', from: 'id', key: ${GoogleTranslationKeys} )
 
// Detect Language:
const bar = await  detect('Nasi goreng', { key: ${GoogleTranslationKeys} )

Authors and thanks

Current package and development: Thofik Wiranata

Readme

Keywords

Package Sidebar

Install

npm i google-translate-api-wrapper

Weekly Downloads

6

Version

1.0.4

License

ISC

Unpacked Size

15.2 kB

Total Files

3

Last publish

Collaborators

  • thofik93