This package allows you to translates a string of text from one language to another.
- Go to the projects page
- Select or create a Cloud Platform Console project.
- Enable billing for your project.
- Click Continue to enable the Translate API and any related services.
- 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.
- Go to the translate api overview and press the "Enable" button.
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. All supported languages |
sourceLanguage |
string | The ISO 639-1 language code the source input is written in. All supported languages |
{
"apiKey": "XXXXXXX",
"string": "Hello",
"sourceLanguage": "en",
"targetLanguage": "es"
}
{
"callback": "success",
"contextWrites": {
"#": {
"to": "Hola"
}
}
}
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. All supported languages |
{
"apiKey": "XXXXXXX",
"string": "Hello",
"targetLanguage": "es"
}
{
"callback": "success",
"contextWrites": {
"#": {
"to": "Hola"
}
}
}
Detect language of string
Field | Type | Description |
---|---|---|
apiKey |
string | Required: The api key obtained from Google Cloud. |
string |
string | Required: The string to translate. |
{
"apiKey": "XXXXXXX",
"string": "Hello",
}
{
"callback": "success",
"contextWrites": {
"#": {
"to": "en"
}
}
}