https://github.com/andre-araujo/aws-translate-json
Translate object values into other languages using the AWS translate API
https://github.com/andre-araujo/aws-translate-json
aws aws-sdk aws-translate js json json-parser object translation
Last synced: 11 months ago
JSON representation
Translate object values into other languages using the AWS translate API
- Host: GitHub
- URL: https://github.com/andre-araujo/aws-translate-json
- Owner: andre-araujo
- License: mit
- Created: 2019-04-25T16:51:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-27T10:38:42.000Z (about 7 years ago)
- Last Synced: 2024-12-01T16:49:32.049Z (over 1 year ago)
- Topics: aws, aws-sdk, aws-translate, js, json, json-parser, object, translation
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS Translate JSON
Translate object values into other languages using the AWS translate API
## Install as a npm package
- `npm install aws-translate-json`
## Usage
### Create an AWS account (Skip this step if you already have one):
- Create an account [here](https://aws.amazon.com).
*There is a free tier to use the translation API that you can check [here](https://aws.amazon.com/pt/translate/pricing/).*
### Create an IAM account with AWS Translation permissions only (Recommended):
- Login on AWS console and navigate to [IAM panel](https://console.aws.amazon.com/iam/home)
- Click on `Users` tab
- Click on `Add User` button
- Follow the steps and add a `User` with access to the Translation API only
- Store the `access key` and the `secret` in a secure place
### Usage example:
```javascript
const { AWSTranslateJSON } = require('aws-translate-json');
const awsConfig = {
accessKeyId: process.env.AWS_TRANSLATE_ID,
secretAccessKey: process.env.AWS_TRANSLATE_SECRET,
region: process.env.AWS_TRANSLATE_REGION,
}
const source = "en";
const taget = ["pt", "it", "es"];
const { translateJSON } = new AWSTranslateJSON(awsConfig, source, taget);
translateJSON({
key1: "my text here",
key2: "other text",
key3: {
key4: "nested text"
}
}).then(console.log);
/* OUTPUT:
{
pt: {
key1: 'meu texto aqui',
key2: 'outro texto',
key3: {
key4: 'texto aninhado'
}
},
it: {
key1: 'il mio testo qui',
key2: 'altro testo',
key3: {
key4: 'testo nidificato'
}
},
es: {
key1: 'mi texto aquí',
key2: 'otro texto',
key3: {
key4: 'texto anidado'
}
}
}
*/
```