A check for language support and status.
Use this class to check and see whether the framework supports the language or language pairing
you want to offer as a translation. For example, to check if someone's device supports a translation
you can do the following:
func translationIsSupported(from source: Locale.Language, to target: Locale.Language) async -> Bool {
let availability = LanguageAvailability()
let status = await availability.status(from: source, to: target)
switch status {
case .installed, .supported:
return true
case .unsupported
return false
}
}
Members (6)
get · iOS 26.4+
preferredStrategy
TypeScript
get preferredStrategy(): TranslationSession_Strategy
Swift declaration
var preferredStrategy: TranslationSession.Strategy { get }
The preferred strategy of translation to check availability for.
Set this property to determine which translation models the framework considers when checking
language availability. ``Translation/TranslationSession/Strategy/lowLatency``
checks for traditional translation models that work on all devices.
``Translation/TranslationSession/Strategy/highFidelity`` checks for Apple
Intelligence models that provide more fluent translations. When Apple Intelligence is enabled, these
models are already downloaded, so translation is immediately available without prompting
the person to download languages.
Creates an instance for checking language availability with a preferred translation strategy.
Set this property to determine which translation models the framework considers when checking
language availability. ``Translation/TranslationSession/Strategy/lowLatency``
checks for traditional translation models that provide faster translations and use less power. ``Translation/TranslationSession/Strategy/highFidelity``
checks for Apple Intelligence models that provide more fluent translations. When Apple Intelligence
is enabled, these models are already downloaded, so translation is immediately available
without prompting the person to download languages. On devices without Apple Intelligence, it falls
back to the traditional models used by `lowLatency`.
get · iOS 18.0+
supportedLanguages
TypeScript
get supportedLanguages(): Promise<Array<_Foundation_Locale_Language>>
Swift declaration
var supportedLanguages: [Locale.Language] { get async }
A list of translation languages the framework supports.
A language must download before it can be used in a translation.
- Returns: An array of languages the framework supports.
Checks to see if the framework supports the language pairing based off a string of sample text.
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.
> Note: For best results in automatic language detection, pass in a sample string
of at least 20 characters in length.
- 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.
- Returns: The availability status for the language pairing to use in the translation.
func status(from source: Locale.Language, to target: Locale.Language?) async -> LanguageAvailability.Status
Checks for the installation of a specific language pairing and whether it's ready for translation.
Use this function to check whether the system has installed the required language assets and the languages are ready to use for translation.
> Note: The framework doesn't support translating from and to the same language.
For example, you can't translate from English (US) to English (UK).
- Parameters:
- source: The source language of the content.
- 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.
- Returns: The availability status for a language pairing.
init · iOS 18.0+
init
TypeScript
static init(): LanguageAvailability
Swift declaration
init()
Creates an instance to check what languages are available.
This initializer uses the default translation strategy based on the SDK version
your app was built with. Apps built with iOS 26.4 or macOS 26.4 SDKs and later
default to checking for Apple Intelligence models when available. Apps built
with earlier SDKs default to traditional models.
To explicitly specify which translation models to check for, use
``init(preferredStrategy:)``.