TeraiTerai

AWS Translate

Neural Machine Translation using Amazon Translate for AWS ecosystem integration.

AWS Translate provides neural machine translation with seamless integration into the AWS ecosystem.

Installation

pnpm add @aws-sdk/client-translate

Authentication

Configure AWS credentials using one of these methods:

Option 1: Environment Variables

export AWS_ACCESS_KEY_ID="your-access-key-id"
export AWS_SECRET_ACCESS_KEY="your-secret-access-key"
export AWS_REGION="us-east-1"

Option 2: AWS CLI Profile

aws configure

Option 3: Pass credentials directly

const translator = createAwsTranslator({
  region: 'us-east-1',
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
  }
})

Usage

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

const translator = createAwsTranslator({
  region: 'us-east-1'
})

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

Options

OptionTypeDefaultDescription
regionstringRequiredAWS region
credentialsobjectAuto-detectedAWS credentials
sourceLanguageCodestring'auto'Source language code

Plus all options from @aws-sdk/client-translate.

Features

  • Neural Machine Translation: High-quality NMT powered by deep learning
  • 75+ Languages: Support for major world languages
  • Auto-detection: Automatic source language detection
  • Custom Terminology: Support for domain-specific translations
  • Active Custom Translation: Train custom models with your data
  • AWS Integration: Seamless integration with other AWS services

Language Codes

AWS Translate uses standard language codes:

LanguageCode
Englishen
Spanishes
Frenchfr
Germande
Japaneseja
Chinese (Simplified)zh
Koreanko
Portuguesept

See AWS documentation for the complete list.

Example with IAM Role

If running on AWS infrastructure (EC2, Lambda, ECS), you can use IAM roles:

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

// Credentials are automatically loaded from the IAM role
const translator = createAwsTranslator({
  region: process.env.AWS_REGION || 'us-east-1'
})

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

Pricing

AWS Translate charges per character translated. See AWS Translate Pricing for current rates.