StructureFoundation5.9.0
Locale
Locale
encapsulates information about linguistic, cultural, and technological conventions and standards. Examples of information encapsulated by a locale include the symbol used for the decimal separator in numbers and the way dates are formatted.
struct Locale
Locales are typically used to provide, format, and interpret information about and according to the user’s customs and preferences. They are frequently used in conjunction with formatters. Although you can use many locales, you usually use the one associated with the current user.
Citizens in Foundation
Conformances
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol ReferenceConvertible
Decorates types which are backed by a Foundation reference type.
Members
init(from: Decoder
) throws init(identifier: String
) Return a locale with the specified identifier.
static var autoupdatingCurrent: Locale
Returns a locale which tracks the user’s current preferences.
static var availableIdentifiers: [String]
Returns a list of available
Locale
identifiers.static var commonISOCurrencyCodes: [String]
Returns a list of common
Locale
currency codes.static var current: Locale
Returns the user’s current locale.
static var isoCurrencyCodes: [String]
Returns a list of available
Locale
currency codes.static var isoLanguageCodes: [String]
Returns a list of available
Locale
language codes.static var isoRegionCodes: [String]
Returns a list of available
Locale
region codes.static var preferredLanguages: [String]
Returns a list of the user’s preferred languages.
static func canonicalIdentifier(from: String
) -> String Returns a canonical identifier from the given string.
static func canonicalLanguageIdentifier(from: String
) -> String Returns a canonical language identifier from the given string.
static func characterDirection(forLanguage: String
) -> Locale.LanguageDirection Returns the character direction for a specified language code.
static func components(fromIdentifier: String
) -> [String : String] Returns a dictionary that splits an identifier into its component pieces.
static func identifier(fromComponents: [String : String]
) -> String Constructs an identifier from a dictionary of components.
static func identifier(fromWindowsLocaleCode: Int
) -> String? Returns the
Locale
identifier from a given Windows locale code, or nil if it could not be converted.static func lineDirection(forLanguage: String
) -> Locale.LanguageDirection Returns the line direction for a specified language code.
static func windowsLocaleCode(fromIdentifier: String
) -> Int? Returns the Windows locale code from a given identifier, or nil if it could not be converted.
var alternateQuotationBeginDelimiter: String?
Returns the alternate quotation begin delimiter of the locale.
var alternateQuotationEndDelimiter: String?
Returns the alternate quotation end delimiter of the locale.
var calendar: Calendar
Returns the calendar for the locale, or the Gregorian calendar as a fallback.
var collationIdentifier: String?
Returns the collation identifier for the locale, or nil if it has none.
var collatorIdentifier: String?
Returns the collator identifier of the locale.
var currencyCode: String?
Returns the currency code of the locale.
var currencySymbol: String?
Returns the currency symbol of the locale.
var debugDescription: String
var decimalSeparator: String?
Returns the decimal separator of the locale.
var description: String
var exemplarCharacterSet: CharacterSet?
Returns the exemplar character set for the locale, or nil if has none.
var groupingSeparator: String?
Returns the grouping separator of the locale.
var identifier: String
Returns the identifier of the locale.
var languageCode: String?
Returns the language code of the locale, or nil if has none.
var quotationBeginDelimiter: String?
Returns the quotation begin delimiter of the locale.
var quotationEndDelimiter: String?
Returns the quotation end delimiter of the locale.
var regionCode: String?
Returns the region code of the locale, or nil if it has none.
var scriptCode: String?
Returns the script code of the locale, or nil if has none.
var usesMetricSystem: Bool
Returns true if the locale uses the metric system.
var variantCode: String?
Returns the variant code for the locale, or nil if it has none.
static func == (Locale, Locale
) -> Bool func encode(to: Encoder
) throws func hash(into: inout Hasher
) func localizedString(for: Calendar.Identifier
) -> String? Returns a localized string for a specified
Calendar.Identifier
.func localizedString(forCollationIdentifier: String
) -> String? Returns a localized string for a specified ICU collation identifier.
func localizedString(forCollatorIdentifier: String
) -> String? Returns a localized string for a specified ICU collator identifier.
func localizedString(forCurrencyCode: String
) -> String? Returns a localized string for a specified ISO 4217 currency code.
func localizedString(forIdentifier: String
) -> String? Returns a localized string for a specified identifier.
func localizedString(forLanguageCode: String
) -> String? Returns a localized string for a specified language code.
func localizedString(forRegionCode: String
) -> String? Returns a localized string for a specified region code.
func localizedString(forScriptCode: String
) -> String? Returns a localized string for a specified script code.
func localizedString(forVariantCode: String
) -> String? Returns a localized string for a specified variant code.
typealias LanguageDirection
typealias ReferenceType