1.0.2 • Published 5 years ago
translate-json-api v1.0.2
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'
}
}