StructureFoundationEssentials
Locale.Language
iOS 16.0+
iPadOS 16.0+
Mac Catalyst 16.0+
macOS 13.0+
tvOS 16.0+
watchOS 9.0+
A type that represents a language, as used in a locale.
struct Language
Topics
Structures
struct ComponentsA type that identifies a language by its various components.
Initializers
init(components: Locale.Language.Components)Creates a language from its component values.init(from: any Decoder) throwsinit(identifier: String)Creates aLanguagewith the language identifierinit(languageCode: Locale.LanguageCode?, script: Locale.Script?, region: Locale.Region?)Creates a language from a given language code, script, and region.
Instance Properties
var characterDirection: Locale.LanguageDirectionThe ordering of characters within a line.var languageCode: Locale.LanguageCode?The language code that identifies the language. Returnsnilif it cannot be determined.var lineLayoutDirection: Locale.LanguageDirectionOrdering of lines within a page. For example, top-to-bottom for English; right-to-left for Mongolian in the Mongolian Scriptvar maximalIdentifier: StringReturns a BCP-47 identifier that always includes the script: “zh-Hant-TW”, “en-Latn-US”var minimalIdentifier: StringReturns a BCP-47 identifier in a minimalist form. Script and region may be omitted. For example, “zh-TW”, “en”var parent: Locale.Language?The parent language of this language, if available.var region: Locale.Region?The region of the language. Returnsnilif it cannot be determined.var script: Locale.Script?The script of the language. Returnsnilif it cannot be determined.
Instance Methods
func hasCommonParent(with: Locale.Language) -> BoolReturns a Boolean value that indicates if the given language shares a common parent with this language.func isEquivalent(to: Locale.Language) -> BoolReturns a Boolean value that indicates whether this language and another language are equivalent after expanding missing components.
Type Properties
static var systemLanguages: [Locale.Language]An array of the system’s supported languages.
Relationships
Conforms To
Swift.DecodableSwift.EncodableSwift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype