# General Translation Platform: translateMany
URL: https://generaltranslation.com/en-US/docs/platform/core/reference/gt-class-methods/translation/translate-many.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Translate multiple strings or structured content entries in one request. API reference for translateMany.

Translates multiple content entries in a single General Translation API request. Use it for batch translation — it is more efficient than issuing many individual [`translate`](/docs/platform/core/reference/gt-class-methods/translation/translate) calls.

## Overview [#overview]

Call `translateMany` on a configured [`GT`](/docs/platform/core/reference/gt-class/constructor) instance with a collection of entries and either a target locale string (shorthand) or an options object. It accepts the entries as an array or as a record keyed by hash, and returns results in the matching shape.

```typescript
const gt = new GT({ apiKey: 'your-api-key', projectId: 'your-project-id' });

const results = await gt.translateMany(
  ['Hello, world!', 'Welcome to our app', 'Click here to continue'],
  'es'
);
```

Signature:

```typescript
// Overload 1: array of entries
translateMany(
  sources: TranslateManyEntry[],
  options: string | TranslateOptions,
  timeout?: number
): Promise<TranslateManyResult>

// Overload 2: record of entries keyed by hash
translateMany(
  sources: Record<string, TranslateManyEntry>,
  options: string | TranslateOptions,
  timeout?: number
): Promise<Record<string, TranslationResult>>
```

*Note: `translateMany` requires an API key (including the deprecated `devApiKey` alias), plus `projectId` on the GT instance.*

## How it works [#how-it-works]

- **Array vs. record.** With an array, entries are hashed internally and results are returned in input order. With a record, the keys are treated as hashes and the response is a record with the same keys.
- **Independent results.** Individual translation failures do not stop the batch — each result reports success or failure on its own, so partial success is fully supported.
- **Options shorthand.** Passing a string for `options` is shorthand for `{ targetLocale: string }`, so `gt.translateMany(['Hello'], 'es')` and `gt.translateMany(['Hello'], { targetLocale: 'es' })` are equivalent.
- **Whole documents.** Set [`metadata.fileFormat`](/docs/platform/core/reference/types/entry-metadata#file-format) to `'MD'` or `'MDX'` to parse and translate a complete document while preserving its structure. The document must be a string with `dataFormat: 'STRING'`, which is the default, and cannot use `maxChars`. A document entry fails instead of returning partial output when a chunk fails or the translated document is invalid.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`sources`](#sources) | Array or record of entries to translate. | [`TranslateManyEntry[] \| Record<string, TranslateManyEntry>`](/docs/platform/core/reference/types/translate-many-entry) | No | — |
| [`options`](#options) | Target locale string, or an options object. | `string \| TranslateOptions` | No | — |
| [`timeout`](#timeout) | Request timeout in milliseconds. | `number` | Yes | — |

### `sources` [#sources]

**Type** [`TranslateManyEntry[] \| Record<string, TranslateManyEntry>`](/docs/platform/core/reference/types/translate-many-entry) · **Required**

The entries to translate. Each [`TranslateManyEntry`](/docs/platform/core/reference/types/translate-many-entry) is a plain string, or an object with `source` (the [`Content`](/docs/platform/core/reference/types/content)) and optional `metadata` (an [`EntryMetadata`](/docs/platform/core/reference/types/entry-metadata)):

```typescript
type TranslateManyEntry = string | { source: Content; metadata?: EntryMetadata };
```

Pass an array to get results back in input order, or a record keyed by hash to get results back under the same keys.

### `options` [#options]

**Type** `string | TranslateOptions` · **Required**

A target locale string such as `'es'`, or an options object:

```typescript
type TranslateOptions = {
  targetLocale: string; // locale to translate into
  sourceLocale?: string; // overrides the instance sourceLocale
  modelProvider?: string; // validated before fetch
  [key: string]: unknown; // extension metadata, not transport options
};
```

Import [`TranslateOptions`](/docs/platform/core/reference/types/translation-config#translate-options) from `generaltranslation/types`. Unsupported `modelProvider` values reject before fetch. (See [accepted providers and entitlements](/docs/platform/core/reference/types/enqueue-files-options#modelprovider)).

### `timeout` [#timeout]

**Type** `number` · **Optional**

Request timeout in milliseconds; omission or `0` selects 60000 ms. Only numbers are accepted, not `false`. This is separate from [request transport configuration](/docs/platform/core/reference/types/translation-config).

## Returns [#returns]

**Type** `Promise<TranslateManyResult> | Promise<Record<string, TranslationResult>>`

- **Array input** resolves to a [`TranslateManyResult`](/docs/platform/core/reference/types/translate-many-result) (an array of [`TranslationResult`](/docs/platform/core/reference/types/translation-result) objects), in the same order as the input.
- **Record input** resolves to a `Record<string, TranslationResult>`, keyed by the same hashes as the input.

Narrow each result on `success` before reading its translation. Runtime translation disables transport retries, including `402` and `429` responses. A `402` response means the Organization's billing account is blocked, or its plan usage limit, monthly spend limit, or credit balance does not cover the request. Configuration, authentication, HTTP, network, cancellation, and timeout failures can reject the whole batch. Results retain the service locale rather than restoring configured aliases. (See [Errors](/docs/platform/core/reference/api-client#types-errors)).

## Examples [#examples]

```typescript
// Array of strings
const results = await gt.translateMany(['Home', 'About', 'Products', 'Contact'], 'fr');

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

```typescript
// Array with per-entry metadata
const results = await gt.translateMany(
  [
    { source: 'Hello, world!', metadata: { dataFormat: 'ICU' } },
    { source: 'Goodbye, world!' },
  ],
  { targetLocale: 'es' }
);
```

```typescript
// Translate a complete MDX document.
const [result] = await gt.translateMany(
  [
    {
      source: '# Welcome\n\n<Callout>Read the guide.</Callout>',
      metadata: { fileFormat: 'MDX' },
    },
  ],
  { sourceLocale: 'en', targetLocale: 'es' }
);
```

```typescript
// Record keyed by hash — results come back under the same keys
const results = await gt.translateMany(
  {
    'greeting-hash': 'Hello, world!',
    'farewell-hash': 'Goodbye, world!',
  },
  'es'
);

const greeting = results['greeting-hash'];
if (greeting?.success) {
  console.log(greeting.translation);
}
```

## Notes [#notes]

- Translates multiple entries in a single API request.
- A failure in one entry does not affect the others.
- Results keep the same order as the input array, or the same keys as the input record.

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
