An object that encapsulates information about linguistic, cultural, and technological conventions and standards, such as date formats, decimal separators, and currency symbols.
- iOS 2.0+
- macOS 10.4+
- tvOS 9.0+
- watchOS 2.0+
You typically use a locale to format and interpret information about and according to the user’s customs and preferences.
You can initialize any number of locale instances with the
init(localeIdentifier:) method using one of the locale identifiers found in the
availableLocaleIdentifiers array. However, you usually use a locale configured to match the preferences of the current user. For convenience, the
autoupdatingCurrent class property provides a locale that remains up to date with the user's configuration settings:
If you need a locale that matches the user's preferences at the moment you read it, but that doesn't change when the user makes configuration changes, use the locale found on the
current property instead. If you need to be alerted when the user does make changes to region settings, register for the
You can inspect a locale by reading its properties, as listed in Getting Information About a Locale. For properties containing a code or identifier, you can then obtain a string suitable for presentation to the user with the methods listed in Getting Display Information About a Locale. For example, you can report the user's language as a string localized in that language using the autoupdating locale obtained in the previous example:
You frequently use a locale in conjunction with a formatter. For example, the
DateFormatter class has a
locale property that ensures dates are converted to strings that match the user's expectations about date formatting. By default, this property indicates the user's current locale, which is usually the behavior you want, but you can instead set it to another locale instance to obtain a different output. See Data Formatting Guide for more information about working with formatters.