Types

TranslateManyResult

Type definition for results returned by batch translation operations

Overview

TranslateManyResult represents the result of batch translation operations with translateMany.

type TranslateManyResult = Array<TranslationResult>;

Structure

Array of TranslationResult objects, maintaining the same order as input entries.

type TranslationResult = RequestSuccess | TranslationError;

Examples

Basic Usage

import { GT, TranslateManyResult } from 'generaltranslation';

const gt = new GT({
  apiKey: 'your-api-key',
  sourceLocale: 'en'
});

const entries = [
  { source: 'Hello', targetLocale: 'es' },
  { source: 'Goodbye', targetLocale: 'es' }
];

const results: TranslateManyResult = await gt.translateMany(entries);

Error Handling

results.forEach((result, index) => {
  if ('error' in result) {
    console.error(`Entry ${index} failed: ${result.error}`);
  } else {
    console.log(`Entry ${index}: ${result.translation}`);
  }
});

How is this guide?

TranslateManyResult