---
title: "locale(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/floatingpointformatstyle/locale(_:)"
---

# locale(_:)

Modifies the format style to use the specified locale.

## Declaration

```swift
func locale(_ locale: Locale) -> FloatingPointFormatStyle<Value>
```

## Parameters

- `locale`: The locale to apply to the format style.

## Return Value

Return Value A floating-point format style modified to use the provided locale.

## Discussion

Discussion Use this modifier to change the locale that an existing format style uses. To instead determine the locale this format style uses, use the locale property. The following example creates a default FloatingPointFormatStyle for the en_US locale, and applies the notation(_:) modifier to use compact name notation. Next, the sample creates a second style based on this first style, but using the German (DE) locale. It then applies each style to an array of floating-point values. let compactStyle = FloatingPointFormatStyle<Double>(locale: Locale(identifier: "en_US"))     .notation(.compactName) let germanStyle = compactStyle.locale(Locale(identifier: "DE")) let nums: [Double] = [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."]

## See Also

### Customizing style behavior

- [decimalSeparator(strategy:)](foundation/floatingpointformatstyle/decimalseparator(strategy:).md)
- [grouping(_:)](foundation/floatingpointformatstyle/grouping(_:).md)
- [notation(_:)](foundation/floatingpointformatstyle/notation(_:).md)
- [precision(_:)](foundation/floatingpointformatstyle/precision(_:).md)
- [rounded(rule:increment:)](foundation/floatingpointformatstyle/rounded(rule:increment:).md)
- [scale(_:)](foundation/floatingpointformatstyle/scale(_:).md)
- [sign(strategy:)](foundation/floatingpointformatstyle/sign(strategy:).md)
- [FloatingPointFormatStyle.Configuration](foundation/floatingpointformatstyle/configuration.md)
- [NumberFormatStyleConfiguration](foundation/numberformatstyleconfiguration.md)
