sourceText
TypeScriptget sourceText(): stringSwift declarationlet sourceText: StringThe original text to translate from.
struct · iOS 18.0+ · SDK 27.1
struct ResponseThe response to a translation request. You get a single response structure after you translate a string, or when you call one of the batch translation methods passing in an array of translation requests. When the translation completes, a response instance returns with the translation result along with properties the framework used to perform the translation.
get sourceText(): stringSwift declarationlet sourceText: StringThe original text to translate from.
get targetText(): stringSwift declarationlet targetText: StringThe translated text.
static initSourceLanguageTargetLanguageSourceAttributedTextTargetAttributedTextClientIdentifier(sourceLanguage: _Foundation_Locale_Language, targetLanguage: _Foundation_Locale_Language, sourceAttributedText: _Foundation_AttributedString, targetAttributedText: _Foundation_AttributedString, clientIdentifier?: (string) | null): TranslationSession_ResponseSwift declarationinit(sourceLanguage: Locale.Language, targetLanguage: Locale.Language, sourceAttributedText: AttributedString, targetAttributedText: AttributedString, clientIdentifier: String? = nil)Creates an instance of a translation response with formatted text. You don't normally use this initializer directly. Instead, let the translation functions create instances of this type for you. Use this initializer when you want to create sample response for a test, for example in a SwiftUI preview.
static initSourceLanguageTargetLanguageSourceTextTargetTextClientIdentifier(sourceLanguage: _Foundation_Locale_Language, targetLanguage: _Foundation_Locale_Language, sourceText: string, targetText: string, clientIdentifier?: (string) | null): TranslationSession_ResponseSwift declarationinit(sourceLanguage: Locale.Language, targetLanguage: Locale.Language, sourceText: String, targetText: String, clientIdentifier: String? = nil)Creates an instance of a translation response. You don't normally use this initializer directly. Instead, let the translation functions create instances of this type for you. Use this initializer when you want to create sample response for a test, for example in a SwiftUI preview.
get sourceLanguage(): _Foundation_Locale_LanguageSwift declarationlet sourceLanguage: Locale.LanguageThe language that the framework translated the text from.
get targetLanguage(): _Foundation_Locale_LanguageSwift declarationlet targetLanguage: Locale.LanguageThe language that the framework translated the text into.
get clientIdentifier(): (string) | nullSwift declarationlet clientIdentifier: String?The unique identifier matching the client identifier set in the translation request. Use this identifier to associate a translation request with its response. If you set a client identifier in the translation request, that same identifier returns in the response. If the request contained no identifier, this value is `nil`.
get attributedSourceText(): (_Foundation_AttributedString) | nullSwift declarationlet attributedSourceText: AttributedString?The original translated text, including style formatting and links. When translating attributed strings using any translation method, the framework makes a best effort to preserve both visual formatting and defined attributes. This enables use cases like timestamp synchronization for captions or lyrics. For examples of translating text with preserved attributes, see ``TranslationSession/Request/attributedSourceText``.
get attributedTargetText(): (_Foundation_AttributedString) | nullSwift declarationlet attributedTargetText: AttributedString?The translated formatted text. This property contains the translated text with formatting and defined attributes preserved and aligned from the source text. The framework makes a best effort to preserve attributes like accessibility instructions and time ranges, aligning them to the corresponding words in the target language. > Note: The framework preserves but doesn't modify attributes. To use the correct language after translation, update any attributes that need to reflect the target language, such as the language modifier for VoiceOver. For examples of translating attributed source text, see ``TranslationSession/Request/attributedSourceText``.
No declarations were skipped in this snapshot.