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 instanceregion
- required string - the region from your azure congnitive services instancetoLangs
- required string[] - array of locale codes to translate the source content tofromLang
- 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
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
{
"org": "Organization",
"currOrg": "Current Organization",
"account": "Account"
}
Language Ouptut File(s)
{
"org": "Organización",
"currOrg": "Organización actual",
"account": "Cuenta"
}
{
"org": "組織",
"currOrg": "現在の組織",
"account": "アカウント"
}