google-translate-api-wrapper
v1.0.4
Published
google translate api wrapper
Readme
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-wrapperThen 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
