1.0.2 • Published 5 years ago

translate-json-api v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Translate-JSON-API

Description

Translate any json for you web page with google translate api

Api

const api = require('translate-json-api');

How to use ?

const trans = new api.JsonTranslate(test); //test here is a json variable
const my_function = async () => {
    const res = await trans.translate("en"); //en => English you can put any language
};

Example

const test = {
    body: "salut comment tu vas ?",
    content: {
        liste: ["ceci est une liste", "deuxieme element"],
        str: "ceci est un string"
    }
}
const start = async () => {
    const trans = new api.JsonTranslate(test);
    const res = await trans.translate("en");
    console.log(res);
};
start();
//Result
{
  body: 'hi how are you?',
  content: {
    list: [ 'this is a list', 'second element' ],
    str: 'this is a string'
  }
}
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago