This package allows to translates a sting of text from one language to another
JavaScript
Latest commit ed283fc Dec 9, 2016 @dimashirokov dimashirokov descr
Permalink
Failed to load latest commit information.
api descr Dec 9, 2016
instructions enable api Sep 15, 2016
lib refact Dec 8, 2016
test code style Sep 13, 2016
.gitignore /ytanslate block Sep 13, 2016
.npmignore create .npmignore file Sep 14, 2016
Dockerfile updated dockerfile Sep 14, 2016
Procfile /ytanslate block Sep 13, 2016
README.md refact Dec 8, 2016
index.js Update index.js Sep 14, 2016
package.json Update package.json Sep 14, 2016

README.md

Google Translate Package

This package allows you to translates a string of text from one language to another.

How to get apiKey:

  1. Go to the projects page
  2. Select or create a Cloud Platform Console project. Creating project
  3. Enable billing for your project.
  4. Click Continue to enable the Translate API and any related services.
  5. On the Credentials page, get an API key (select Browser key when prompted). Note: If you have an existing API key, you can use that key.
  6. Go to translate api overview and press Enable button.

    Enable API

GoogleTranslate.translate

Translate string from sourceLanguage to targetLanguage

Field Type Description
apiKey string Required: The api key obtained from Google Cloud.
string string Required: The string to translate.
targetLanguage string Required: The ISO 639-1 language code to translate the input to.
sourceLanguage string The ISO 639-1 language code the source input is written in.

Request example

{
    "apiKey": "XXXXXXX",
    "string": "Hello",
    "sourceLanguage": "en",
    "targetLanguage": "es"
}

Response example

{
    "callback": "success",
    "contextWrites": {
        "#": {
            "to": "Hola"
        }
    }
}

GoogleTranslate.translateAutomatic

Translate string from sourceLanguage to target language automatically

Field Type Description
apiKey string Required: The api key obtained from Google Cloud.
string string Required: The string to translate.
targetLanguage string Required: The ISO 639-1 language code to translate the input to.

Request example

{
    "apiKey": "XXXXXXX",
    "string": "Hello",
    "targetLanguage": "es"
}

Response example

{
    "callback": "success",
    "contextWrites": {
        "#": {
            "to": "Hola"
        }
    }
}

GoogleTranslate.detectLanguage

Detect language of string

Field Type Description
apiKey string Required: The api key obtained from Google Cloud.
string string Required: The string to translate.

Request example

{
    "apiKey": "XXXXXXX",
    "string": "Hello",
}

Response example

{
    "callback": "success",
    "contextWrites": {
        "#": {
            "to": "en"
        }
    }
}