---
title: "components(fromLocaleIdentifier:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nslocale/components(fromlocaleidentifier:)"
---

# components(fromLocaleIdentifier:)

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

## Declaration

```swift
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

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.

## Discussion

Discussion For example, the locale identifier "en_US@calendar=japanese" yields a dictionary with three entries: languageCode = en countryCode = US calendar = NSJapaneseCalendar

## See Also

### Converting Between Identifiers

- [canonicalLocaleIdentifier(from:)](foundation/nslocale/canonicallocaleidentifier(from:).md)
- [localeIdentifier(fromComponents:)](foundation/nslocale/localeidentifier(fromcomponents:).md)
- [canonicalLanguageIdentifier(from:)](foundation/nslocale/canonicallanguageidentifier(from:).md)
- [localeIdentifier(fromWindowsLocaleCode:)](foundation/nslocale/localeidentifier(fromwindowslocalecode:).md)
- [windowsLocaleCode(fromLocaleIdentifier:)](foundation/nslocale/windowslocalecode(fromlocaleidentifier:).md)
