Creates a language from its component values.
- Parameter components: A `Language.Components` instance that provides a custom language code, region, and script for the new `Language` instance.
Returns a Boolean value that indicates whether this language and another language are equivalent after expanding missing components.
- Parameter language: A language to compare equivalence with.
- Returns: `true` if the two languages are equivalent; `false` otherwise.
The following example shows equivalence tests run on various ways of expressing the US English language, followed by a test against UK English.
```swift
let en = Locale.Language(identifier: "en")
let enUS = Locale.Language(identifier: "en-US")
let enLatn = Locale.Language(identifier: "en-Latn")
let enLatnUS = Locale.Language(identifier: "en-Latn-US")
let test1 = en.isEquivalent(to: enUS) // true
let test2 = en.isEquivalent(to: enLatn) // true
let test3 = en.isEquivalent(to: enLatnUS) // true
let enUK = Locale.Language(identifier: "en-UK")
let test4 = en.isEquivalent(to: enUK) // false
```
Creates a language from a given language code, script, and region.
- Parameters:
- languageCode: A language code, typically created from a two- or three-letter language code specified by ISO 639.
- script: The script to use for the new locale components instance.
- region: The region to use for the new components instance.
get · iOS 16.0+
languageCode
TypeScript
get languageCode(): (Locale_LanguageCode) | null
Swift declaration
var languageCode: Locale.LanguageCode? { get }
The language code that identifies the language. Returns `nil` if it cannot be determined.
Returns a Boolean value that indicates if the given language shares a common parent with this language.
- Parameter language: A language to compare parentage with.
- Returns: `true` if this language and `language` share a common parent; `false` otherwise.
get · iOS 16.0+
systemLanguages
TypeScript
static get systemLanguages(): Array<Locale_Language>
Swift declaration
static var systemLanguages: [Locale.Language] { get }
An array of the system's supported languages.
The returned array includes the languages of all product localizations for the current platform.
get · iOS 16.0+
maximalIdentifier
TypeScript
get maximalIdentifier(): string
Swift declaration
var maximalIdentifier: String { get }
Returns a BCP-47 identifier that always includes the script: "zh-Hant-TW", "en-Latn-US"
get · iOS 16.0+
minimalIdentifier
TypeScript
get minimalIdentifier(): string
Swift declaration
var minimalIdentifier: String { get }
Returns a BCP-47 identifier in a minimalist form. Script and region may be omitted. For example, "zh-TW", "en"
get · iOS 16.0+
characterDirection
TypeScript
get characterDirection(): NSLocale_LanguageDirection
Swift declaration
var characterDirection: Locale.LanguageDirection { get }
The ordering of characters within a line.
For example, English uses left-to-right while Mongolian in the Mongolian script uses top-to-bottom.
get · iOS 16.0+
lineLayoutDirection
TypeScript
get lineLayoutDirection(): NSLocale_LanguageDirection
Swift declaration
var lineLayoutDirection: Locale.LanguageDirection { get }
Ordering of lines within a page.
For example, top-to-bottom for English; right-to-left for Mongolian in the Mongolian Script
- note: See also `characterDirection`.
get · iOS 16.0+
parent
TypeScript
get parent(): (Locale_Language) | null
Swift declaration
var parent: Locale.Language? { get }
The parent language of this language, if available.
For example, the parent language of `en_US_POSIX` is `en_US`.
If the system can't determine a parent language, this value is `nil`.
get · iOS 16.0+
region
TypeScript
get region(): (Locale_Region) | null
Swift declaration
var region: Locale.Region? { get }
The region of the language. Returns `nil` if it cannot be determined.
get · iOS 16.0+
script
TypeScript
get script(): (Locale_Script) | null
Swift declaration
var script: Locale.Script? { get }
The script of the language. Returns `nil` if it cannot be determined.