Skip to content

A command line tool to translate JSON files using AWS Translate.

License

Notifications You must be signed in to change notification settings

marcguillemdev/AWS-JSON-TRANSLATOR-CLI

Repository files navigation

cli icon AWS JSON TRANSLATOR CLI

AWS JSON TRANSLATOR CLI is a command line application to translate JSON files using AWS Translate.

Table of contents

🔧 Features

  • 📄 Deep and non-deep JSON Files (support for JSON Arrays too)
  • 👔 Support for formality and profanity (to view supported languages see the links below)
  • 🔑 Easy configuration of keys and region with a "set-configuration" command.
  • 📃 Translate without altering the structure.

💻 Usage

Create an IAM account with AWS Translation:

  • Login on AWS console and navigate to IAM panel
  • Click on Users tab
  • Click on Add User button
  • Follow the steps and add a User with access to the Translation API only
  • Save the access key and the secret in a secure place

Available regions: AWS Regions documentation With both keys and region, we are ready to do the configuration.

Running configuration

  1. Configure Access Key, Secret Key and Region using "set-configuration" command specifying parameters.

    • --awsAccessKey. OPTIONAL. Your AWS Access Key from IAM User.
    • --awsSecretKey. OPTIONAL. Your AWS Secret Key from IAM User.
    • --awsRegion. OPTIONAL. Your AWS Region.

All parameters are optional, so you can set individually each property if you want.

Run .exe

.\aws-json-translator.exe set-configuration --awsAccessKey exampleAccessKey --awsSecretKey exampleSecretKey --awsRegion eu-west-3

Run .jar

java -jar aws-json-translator.jar set-configuration --awsAccessKey exampleAccessKey --awsSecretKey exampleSecretKey --awsRegion eu-west-3
  1. Translate JSON file using "translate-json" command specifying required parameters.

    • -sl or --sourceLanguage. REQUIRED. Source language of JSON in ISO 3166 alpha-2 code.
    • -tl or --targetLanguage. REQUIRED. Target language you want to translate to in ISO 3166 alpha-2 code.
    • -sf or --sourceFile. REQUIRED. Source file containing JSON to translate.
    • --enableProfanityFilter. OPTIONAL. Enable profanity filter. (Empty parameter)
    • --formality. OPTIONAL. Formality level. Possible values: formal, informal. Default: formal
    • --customTerminology. OPTIONAL. Custom terminology name list separated by comma.

To use custom terminology, you have to create a custom terminology in Amazon Translate and then put the name in --customTerminology parameter. For more information, see Amazon Translate Custom Terminology.

Basic usage of "translate-json"


Run .exe

.\aws-json-translator.exe translate-json -sf example.json -sl es -tl en

Run .jar

java -jar aws-json-translator.jar translate-json -sf example.json -sl es -tl en

This command will translate the file example.json from Spanish to English

Extended usage of "translate-json"


Run .exe

.\aws-json-translator.exe translate-json --sourceFile example.json --sourceLanguage es --targetLanguage en --formality formal --enableProfanityFilter --customTerminology list1,list2

Run .jar

java -jar aws-json-translator.jar translate-json --sourceFile example.json --sourceLanguage es --targetLanguage en --formality formal --enableProfanityFilter --customTerminology list1,list2

This command will translate the file example.json from Spanish to English with formality formal, with enabled profanity filter and a list of custom terminologies

  1. Done! Your translated JSON is on .\output folder with the target language code as name.

👩‍💻 Credits and used technologies

💼 License

MIT License

Copyright (c) 2022 Marc Guillem Dev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.