Platforms to show: All Mac Windows Linux Cross-Platform
Back to TranslationSessionMBS class.
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Future requests will throw an error that the session is already cancelled.
Requires macOS 26.0 or iOS 26.0 or later.
TranslationSessionMBS.Constructor(fromLanguageIdentifier as String, toLanguageIdentifier as String = "")
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
If one or both of the languages aren't installed on the device already, attempting to translate will throw errors.
toLanguageIdentifier is optional and if empty will default to the users current locale.
TranslationSessionMBS.isReady as Boolean
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Waits for callback and returns result.
Requires macOS 26.0 or iOS 26.0 or later.
See also:
TranslationSessionMBS.isReady(completed as TranslationReadyCompletedMBS, Tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Use this property to check whether a translation is likely to succeed. In a session that can request downloads, it prompts the person to approve downloads if languages aren't ready yet. In a session that can't request downloads, it will throw an error if the person calls any functions when languages aren't ready.
Note: This value returns whether the languages are currently installed. The person or system can still delete the downloaded languages after calling this, so make sure you handle the appropriate errors when calling one of the translate functions.
The tag value is passed through to the delegate.
Requires macOS 26.0 or iOS 26.0 or later.
See also:
TranslationSessionMBS.prepareTranslation(completed as TranslationPrepareTranslationCompletedMBS, Tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
If you know ahead of time which languages the person needs to translate, you can prompt them to download those languages in advance by calling this method.
When you call this method, the framework asks the person for permission to download the sourceLanguage and targetLanguage. If the languages are already installed or in the middle of downloading, the function returnswithout prompting them.
If you call this function when the sourceLanguage is empty, it unableToIdentifyLanguage error, since there's no sample text to identify which source language to use for translation.
The tag value is passed through to the delegate.
TranslationSessionMBS.translateBatch(Requests() as TranslationRequestMBS, completedOne as TranslateStringCompletedMBS, completed as TranslationsCompletedMBS, Tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This function translates multiple strings of text incrementally and might display different UI depending on the state of the translation. The required languages for translation don't have to be installed before calling this method.
/ Pass in the strings of text you want to translate as an array of the Request type. Set the 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 empty 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 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 usercancelled error, and the languages continue to download in the background.
Note: Calls to this function can take several minutes while languages download.
Calls the completedOne delegate (if not nil) for each translation as they are ready in random order. Then later calls completed event (if not nil)
The tag value is passed through to the delegate.
TranslationSessionMBS.translateString(text as String) as TranslationResponseMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Waits for callback and returns result.
See also:
TranslationSessionMBS.translateString(text as String, completed as TranslateStringCompletedMBS, Tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This function translates a single line of text and might display different UI depending on the state of the translation. The required languages for translation don't have to be installed before calling this method.
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 empty and the framework can't detect the source language from the content, the framework prompts the person to choose the source 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 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 usercancelled error, and the languages continue to download in the background.
Note: This function call can take several minutes while languages download.
The tag value is passed through to the delegate.
See also:
TranslationSessionMBS.translations(Requests() as TranslationRequestMBS) as TranslationResponseMBS()
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Waits for callback and returns result.
See also:
TranslationSessionMBS.translations(Requests() as TranslationRequestMBS, completed as TranslationsCompletedMBS, Tag as Variant = nil)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | Translation | MBS Swift Plugin | 26.0 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This function translates multiple strings as a batch and might display different UI depending on the state of the translation. The languages the framework requires for the translation don't have to be installed before calling this method.
Pass in the strings of text you want to translate as an array of the Request type. This method takes longer to return than translateBatch, but it has the advantage of not having to map translation requests to responses. The responses return in the same order the requests are sent.
If the required languages for translation have already downloaded and the source language is clear, this function returns results without showing any further prompts to the person.
If the source or target language aren't installed, the framework asks the person for permission to download the languages. During download a progress indicator displays. After the download completes, the framework performs the translation.
If the sourceLanguage is empty 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 empty, 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 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 usercancelled error, and the languages continue to download in the background.
Note: Calls to this function can take several minutes while languages download.
The tag value is passed through to the delegate.
See also:
The items on this page are in the following plugins: MBS Swift Plugin.