Never Play Metal

    gulp-azure-translate

    0.3.0 • Public • Published

    Gulp Azure Translate

    Streaming Translation tool using Azure's Cognitive Services

    Installation

    You know the drill...

    $ npm i gulp-azure-translate
    

    Setup

    To use this tool, you'll first need to create an instance of Microsoft Azure's Cognitive Services in your Azure account.

    This plugin calls the v3 translate api.

    Api

    translateAzure(config)

    The config is an object consisting of:

    • apiKey - required string - the api key from your azure congnitive services instance
    • region - required string - the region from your azure congnitive services instance
    • toLangs - required string[] - array of locale codes to translate the source content to
    • fromLang - optional string - the locale code that will be used as the source language (default: determined)
    • slowMode - optional boolean - requests all translations in series. (default: false)
    • showErrors - optional boolean - displays network errors when encountered. (default false)

    Note: apiKey and region are values from the Congnitive Services instance you create in your Azure account. Once created, Check the "Keys and Endpoint" tab to get these values.

    A list of supported languages can be found here.

    Example Gulp Usage

    Gulpfile

    // gulpfile.js
    const { task } = require('gulp');
    const translateAzure = require('gulp-azure-translate');
    
    task('translate', () => {
      return src(['src/en.json'])
        .pipe(translateAzure({
          apiKey: '00000000-00000000-00000000-00000000-0000000000',
          region: 'eastus',
          fromLang: 'en',
          toLangs: ['es', 'ja']
        }))
        .pipe(dest(`./src/translations`))
    })

    Source Language File

    // src/en.json
    {
      "org": "Organization",
      "currOrg": "Current Organization",
      "account": "Account"
    }

    Language Ouptut File(s)

    // src/translations/es.json
    {
      "org": "Organización",
      "currOrg": "Organización actual",
      "account": "Cuenta"
    }
    // src/translations/ja.json
    {
      "org": "組織",
      "currOrg": "現在の組織",
      "account": "アカウント"
    }

    Install

    npm i gulp-azure-translate

    DownloadsWeekly Downloads

    22

    Version

    0.3.0

    License

    ISC

    Unpacked Size

    9.28 kB

    Total Files

    5

    Last publish

    Collaborators

    • ahoran3