<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Translation",
  "identifier" : "/documentation/Translation/TranslationSession/translate(batch:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Translation"
    ],
    "preciseIdentifier" : "s:11Translation0A7SessionC9translate5batchAC13BatchResponseVSayAC7RequestVG_tF"
  },
  "title" : "translate(batch:)"
}
-->

# translate(batch:)

Translates multiple strings of text of the same language, returning a sequence of responses as they’re available.

```
func translate(batch: [TranslationSession.Request]) -> TranslationSession.BatchResponse
```

## Parameters

`batch`

The array of requests to translate.

## Return Value

An `AsyncSequence` of responses containing the text translations.

## Discussion

This function translates multiple strings of text incrementally and might display different UI depending
on the state of the translation.
The app doesn’t need to install the required languages before calling this method.

Pass in the strings of text you want to translate as an array of the [`TranslationSession.Request`](/documentation/Translation/TranslationSession/Request) type.
To create requests for attributed strings, use `Request/init(sourceText:clientIdentifier:)-(AttributedString)`.
Set the [`clientIdentifier`](/documentation/Translation/TranslationSession/Request/clientIdentifier) on each request so you can match the request
with the response as the translations incrementally return.

If the required languages for translation have already downloaded and the source language is clear,
this function returns results without showing any UI to the person.

If the source or target language aren’t installed, the framework asks the person for permission to
download the languages. During the download a progress indicator displays. After it completes,
the framework performs the translation.

If the `sourceLanguage` is `nil` and the framework can’t detect the source language from the content,
the framework prompts the person to choose the source language.

The framework only supports string translations of the same language.
The strings must either match the `sourceLanguage` you set in the configuration,
or if the `sourceLanguage` is `nil`, be of the same language.

This function throws an `Error` if:

- The person doesn’t agree to downloading the languages
- The person dismisses the progress view during language downloads
- [`TranslationSession`](/documentation/Translation/TranslationSession)  fails system validation
- The session doesn’t allow requesting downloads and languages aren’t installed
- You already cancelled the session
- Something goes wrong during translation

If a person dismisses the progress view while the languages download, the system throws a <doc://com.apple.documentation/documentation/Foundation/CocoaError/Code/userCancelled> error, and the languages
continue to download in the background.

> Note: Calls to this function can take several minutes while languages download. The framework
> shows a progress indicator during the download.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)