<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Decimal/FormatStyle/locale(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So9NSDecimala10FoundationE11FormatStyleV6localeyAeC6LocaleVF"
  },
  "title" : "locale(_:)"
}
-->

# locale(_:)

Modifies the format style to use the specified locale.

```
func locale(_ locale: Locale) -> Decimal.FormatStyle
```

## Parameters

`locale`

The locale to apply to the format style.

## Return Value

A decimal format style modified to use the provided locale.

## Discussion

Use this modifier to change the locale that an existing format style uses. To instead determine the locale that this format style uses, use the [`locale`](/documentation/Foundation/Decimal/FormatStyle/locale) property.

The following example creates a default [`Decimal.FormatStyle`](/documentation/Foundation/Decimal/FormatStyle) for the `en_US` locale, and applies the [`notation(_:)`](/documentation/Foundation/Decimal/FormatStyle/notation(_:)) modifier to use compact name notation. Next, the sample creates a second style based on this, but that uses the German (`DE`) locale. It then applies each style to an array of decimal values.

```swift
let compactStyle = Decimal.FormatStyle(locale: Locale(identifier: "en_US"))
    .notation(.compactName)
let germanStyle = compactStyle.locale(Locale(identifier: "DE"))
let nums: [Decimal] = [100, 1000, 10000, 100000, 1000000]
let enUSCompactNums = nums.map { compactStyle.format($0) } // ["100", "1K", "10K", "100K", "1M"]
let deCompactNums = nums.map { germanStyle.format($0) } // ["100", "1000", "10.000", "100.000", "1 Mio."]
```

---

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)