<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSLocale/components(fromLocaleIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLocale(cm)componentsFromLocaleIdentifier:"
  },
  "title" : "components(fromLocaleIdentifier:)"
}
-->

# components(fromLocaleIdentifier:)

Returns a dictionary that is the result of parsing a locale ID.

```
class func components(fromLocaleIdentifier string: String) -> [String : String]
```

## Parameters

`string`

A locale ID, consisting of language, script, country, variant, and keyword/value pairs, for example, `"en_US@calendar=japanese"`.

## Return Value

A dictionary that is the result of parsing `string` as a locale ID. The keys are the constant NSString constants corresponding to the locale ID components, and the values correspond to constants where available. For possible values, see [`NSLocale.Key`](/documentation/Foundation/NSLocale/Key).

## Discussion

For example, the locale identifier `"en_US@calendar=japanese"` yields a dictionary with three entries:

- [`languageCode`](/documentation/Foundation/NSLocale/Key/languageCode) = `en`
- [`countryCode`](/documentation/Foundation/NSLocale/Key/countryCode) = `US`
- [`calendar`](/documentation/Foundation/NSLocale/Key/calendar) = [`NSJapaneseCalendar`](/documentation/Foundation/NSJapaneseCalendar)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)