TeraiTerai

Azure Translator

Neural Machine Translation using Microsoft Azure Translator for Microsoft ecosystem integration.

Azure Translator provides neural machine translation with integration into the Microsoft Azure ecosystem.

Installation

No additional packages required - Azure Translator uses native fetch.

Authentication

You'll need an Azure Translator resource:

  1. Create an Azure account at portal.azure.com
  2. Create a Translator resource in the Azure portal
  3. Get your subscription key and region from the resource

Usage

import { defineConfig, createAzureTranslator } from '@terai/dev'

const translator = createAzureTranslator({
  subscriptionKey: process.env.AZURE_TRANSLATOR_KEY,
  region: process.env.AZURE_TRANSLATOR_REGION // e.g., 'eastus'
})

export default defineConfig({
  projectLocale: 'en-US',
  outLocales: ['es-ES', 'fr-FR', 'de-DE'],
  outDir: './locale',
  translator
})

Options

OptionTypeDefaultDescription
subscriptionKeystringRequiredAzure subscription key
regionstringRequiredAzure region (e.g., 'eastus')
endpointstring'https://api.cognitive.microsofttranslator.com'API endpoint

Features

  • Neural Machine Translation: State-of-the-art NMT models
  • 100+ Languages: Support for a wide range of languages
  • Auto-detection: Automatic source language detection
  • Custom Translator: Train custom models with your terminology
  • Document Translation: Translate entire documents
  • Microsoft Integration: Works with Azure services and Microsoft 365

Environment Variables

export AZURE_TRANSLATOR_KEY="your-subscription-key"
export AZURE_TRANSLATOR_REGION="eastus"

Language Codes

Azure Translator uses BCP 47 language tags:

LanguageCode
Englishen
Spanishes
Frenchfr
Germande
Japaneseja
Chinese (Simplified)zh-Hans
Chinese (Traditional)zh-Hant
Koreanko
Portuguese (Brazil)pt-br

See Azure documentation for the complete list.

Custom Endpoint

For Azure Government or custom deployments:

import { defineConfig, createAzureTranslator } from '@terai/dev'

const translator = createAzureTranslator({
  subscriptionKey: process.env.AZURE_TRANSLATOR_KEY,
  region: process.env.AZURE_TRANSLATOR_REGION,
  endpoint: 'https://your-custom-endpoint.cognitiveservices.azure.com'
})

export default defineConfig({
  projectLocale: 'en-US',
  outLocales: ['es-ES', 'fr-FR'],
  outDir: './locale',
  translator
})

Pricing

Azure Translator offers a free tier with 2M characters/month. See Azure Translator Pricing for details.