Giter Club home page Giter Club logo

trawslate's Introduction

trAWSlate

Want to use Amazon Translate, but used your own "proprietary" json format for your translations and now have to convert everything into AWS's proprietary format?

This is a very simple command line tool that takes my translation file, and the destination language, parses it, fires each it at Amazon Translate and updates my translation document with the result.

Basically I've a translation file that looks like this...

{
  "en": {
    "translation-key-1": "Some text",
    "translation-key-2": "Some more text",
    "translation-key-3": "Even more text"
  },
  "es": {
    "translation-key-1": "Algún texto",
    "translation-key-2": "Un poco más de texto",
    "translation-key-3": "Aún más texto"
  }
}

Amazon Translate requires this...

{
   "SourceLanguageCode": "en",
   "TargetLanguageCode": "es",
   "TerminologyNames": [ "if-you-have-one" ],
   "Text": "Some text"
}

Installing

Clone the repo and run

npm i

Running the command

node index.js examples/translations.json es

Prerequisites

You'll need an AWS account, an IAM role that can use Amazon Translate and node. Obviously you'll need a translation file in the json format above.

A couple of assumptions

  • I've found I need my AWS details in exports for node to run successfully (e.g. export AWS_ACCESS_KEY_ID=XXXX, export AWS_SECRET_ACCESS_KEY=YYYY, AWS_DEFAULT_REGION=eu-west-1)
  • The first language you have in the translation file is the source language
  • You want to have the same translation file for all languages
  • This only supports the languages supported by Amazon Translate - both source and target
  • No it doesn't support XLIFF, or any other translation file type
  • We only scan a single child deep into the JSON
  • No it doesn't support for batching to/from S3

Contributing

Please read CONTRIBUTING.md so you understand the process for submitting pull requests to me.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

trawslate's People

Contributors

mcvicar avatar dependabot[bot] avatar

Stargazers

Shantanu Oak avatar wolfi3 avatar  avatar Mitch Pirtle avatar

Watchers

 avatar James Cloos avatar

trawslate's Issues

Check min/max byte length

Translate has a minimum length of 1 and a maximum length of 5000 bytes long for text to translate.

If a text string is over 5000 bytes I'll need to temporarily spit it into # number of parts so that it can be successfully translated and recompile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.