Skip to content

Directly translate markdown file using AWS Translate Api

Notifications You must be signed in to change notification settings

lpiedade/markdown-translator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown Translator on AWS

Directly translate markdown file using AWS Translate API.

This is a fork of this project.

Prerequisites

  • create AWS credentials (access_key_id and secret_access_key) and assign permissions to the AWS translate API (translate:TranslateText action is sufficient)

Quick Start

Use as cli

# install cli
npm install markdown-translator -g

# set key and region from AWS Translate API
md-translator set --key <your key>
md-translator set --region <your region>

# do translate
md-translator translate --src README.md --from en --dest README.zh.md --to zh

# get more infomation
md-translator --help

In case AWS is being used the credentials are currently fetched from the environment (TODO represent in config).

Use as binaries

Run markdown-translator without Node environment

  • Update config.json with your AWS credential.
  • Run npm run dist:mac to build for macos and npm run dist:win for windows.
  • Run the dist binary files like cli, e.g, ./markdown-translator translate --src README.md --dest README.zh.md --to zh

Modify dist scripts according to your platform. Find more at here

Use as a module

# install module
npm install markdown-translator
const markdownTranslate = require('markdown-translator')
markdownTranslate({
  src: pathToSrcFile,
  from: languageToTranslateFrom,
  to: languageToTranslateTo,
  subscriptionKey: yourSubscriptionKey,
  region: theRegionOfYourAWSInstance
}).then(res => {
  // deal with result
})

Note that there are some opinionated defaults: from is by default 'en', to 'es'. The region argument is optional.

Using Node

node cli.js translate --src README.md --from en --dest README.pt.md --to pt

Credits: @smazanek / @menthays

About

Directly translate markdown file using AWS Translate Api

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%