Skip to content

Automatically translate locale files to multiple languages using Google Cloud Translation API

Notifications You must be signed in to change notification settings

theAlexPatin/transl8-js

Repository files navigation

transl8-js

Instantly translates your locale files into multiple languages using Google's Cloud Translation API.

Installation

npm install -g transl8

From the Command Line

Usage: $ transl8 [options]

Options Description
--key Google Cloud API Key. Register one here (Required)
--infile Your source locale file. .js and .json files are valid (Required)
--outdir Output directory for translated files (Default: ./output)
--locales Target translation tags (Required)
--verbose 1 or true for warnings, 2 for info, 3 for errors (Default false)

Examples

  • transl8 --key $GOOGLE_API_KEY --locales fr es --infile ./en.json
  • transl8 --key $GOOGLE_API_KEY --locales lv --outdir translations --infile ./en.js

Via Node Module

const transl8 = require('transl8')

transl8({
  key: 'XXXXX',
  source: {
    hello: 'Hello World',
  },
  locales: ['fr', 'es'],
  verbose: false,
})
  .then(result => { ... })

Result

{
  "fr": {
    "hello": "Bonjour le monde"
  },
  "es": {
    "hello": "Hola Mundo"
  }
}

About

Automatically translate locale files to multiple languages using Google Cloud Translation API

Topics

Resources

Stars

Watchers

Forks