Locale.Components
A type that represents the components of a locale, for use when creating a locale with specific overrides.
Declaration
struct ComponentsOverview
Use Locale.Components with the init(components:) initializer to create a custom Locale that overrides specific traits of a default locale. When you create a locale with components, the locale uses any overridden values instead of defaults preferred by the region or language. Leave a property nil to accept the default value.
The properties in this type correspond with those in Locale, which declares them as read-only rather than read-write. You use this type to customize components when creating a custom locale, and use Locale to examine the components of an existing locale.
The following example creates a Locale.Components instance for US English, but then customizes its components. It sets the first day of the week to Monday and the hour cycle to zero-to-23. These components override the en-US defaults of Sunday and one-to-12, respectively. It then uses init(components:) to create a custom Locale.
var components = Locale.Components(languageCode: "en", languageRegion: "US")
components.firstDayOfWeek = Locale.Weekday.monday
components.hourCycle = Locale.HourCycle.zeroToTwentyThree
let locale = Locale(components: components)Topics
Creating a locale components instance
Specifying language components
Specifying date and time components
Specifiying measurement and counting components
currencyLocale.CurrencymeasurementSystemLocale.MeasurementSystemnumberingSystemLocale.NumberingSystem