JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 346
  • Score
    100M100P100Q96595F
  • License MIT

Translate JOSN object to any languages via google translate

Package Exports

  • translate-json-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (translate-json-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Translate a JSON Object

Please note this package is still under development

Install

npm install -S translate-json-object

API

var translateObject = require('translate-json-object');
translateObject(srcObject, langageuString, googleTranslateAPITokenString)
Params Type Description
srcObject Object It's the object you want to translate
langageuString String The language you wish to translate too (e.g 'es', 'fr', 'ar'...)
googleTranslateAPITokenString String Your google api key for translate service

Example

First install:

npm install -S translate-json-object

then use:

var translateObject = require('translate-json-object');

var obj = {
  "name": "Please enter your name",
    "click": "click here",
    "nested": {
      "hello": "hello",
      "world": "world"
    }
};

var promise = translateObject(obj, 'es', 'googleTranslateAPIToken');

promise.then(function(data) {
  console.log(data);
    // { name: 'por favor, escriba su nombre',
    //   click: 'haga clic aquí',
    //   nested: { hello: 'Hola', world: 'mundo' } }
});