<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/LocalizedStringKey/init(stringInterpolation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI18LocalizedStringKeyV19stringInterpolationA2C0dG0V_tcfc"
  },
  "title" : "init(stringInterpolation:)"
}
-->

# init(stringInterpolation:)

Creates a localized string key from the given string interpolation.

```
init(stringInterpolation: LocalizedStringKey.StringInterpolation)
```

## Parameters

`stringInterpolation`

The string interpolation to use as the
localization key.

## Discussion

To create a localized string key from a string interpolation, use
the `\()` string interpolation syntax. Swift matches the parameter
types in the expression to one of the `appendInterpolation` methods
in [`LocalizedStringKey.StringInterpolation`](/documentation/SwiftUI/LocalizedStringKey/StringInterpolation). The interpolated
types can include numeric values, Foundation types, and SwiftUI
[`Text`](/documentation/SwiftUI/Text) and [`Image`](/documentation/SwiftUI/Image) instances.

The following example uses a string interpolation with two arguments:
an unlabeled
<doc://com.apple.documentation/documentation/Foundation/Date>
and a [`Text.DateStyle`](/documentation/SwiftUI/Text/DateStyle) labeled `style`. The compiler maps these to the
method
[`appendInterpolation(_:style:)`](/documentation/SwiftUI/LocalizedStringKey/StringInterpolation/appendInterpolation(_:style:))
as it builds the string that it creates the
[`LocalizedStringKey`](/documentation/SwiftUI/LocalizedStringKey) with.

```
let key = LocalizedStringKey("Date is \(company.foundedDate, style: .offset)")
let text = Text(key) // Text contains "Date is +45 years"
```

You can write this example more concisely, implicitly creating a
[`LocalizedStringKey`](/documentation/SwiftUI/LocalizedStringKey) as the parameter to the [`Text`](/documentation/SwiftUI/Text)
initializer:

```
let text = Text("Date is \(company.foundedDate, style: .offset)")
```

---

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)