Contents

status(for:to:)

Checks to see if the framework supports the language pairing based off a string of sample text.

Declaration

func status(for text: String, to target: Locale.Language?) async throws -> LanguageAvailability.Status

Parameters

  • text:

    A sample string of text representing the source language you want to translation from.

  • target:

    The target language you want to translate content into. When set to nil, the system picks an appropriate target based on the person’s preferred languages and returns the status for those languages.

Return Value

The availability status for the language pairing to use in the translation.

Discussion

Use this function when you don’t know the source language and want the framework to attempt a translation based on the sample text you pass in.

Pass in a string of sample text representing the language you want to translate from. When you do, the system automatically tries to detect the language of the text you pass in. If it can’t, it throws a TranslationError.

If it can detect the source language of the text, it checks for necessary language asset downloads and whether they’re ready for use.

See Also

Checking language availability