<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI18LocalizedStringKeyV"
  },
  "title" : "LocalizedStringKey"
}
-->

# LocalizedStringKey

The key used to look up an entry in a strings file or strings dictionary
file.

```
@frozen struct LocalizedStringKey
```

## Overview

Initializers for several SwiftUI types – such as [`Text`](/documentation/SwiftUI/Text), [`Toggle`](/documentation/SwiftUI/Toggle),
[`Picker`](/documentation/SwiftUI/Picker) and others –  implicitly look up a localized string when you
provide a string literal. When you use the initializer `Text("Hello")`,
SwiftUI creates a `LocalizedStringKey` for you and uses that to look up a
localization of the `Hello` string. This works because `LocalizedStringKey`
conforms to
<doc://com.apple.documentation/documentation/Swift/ExpressibleByStringLiteral>.

Types whose initializers take a `LocalizedStringKey` usually have
a corresponding initializer that accepts a parameter that conforms to
<doc://com.apple.documentation/documentation/Swift/StringProtocol>. Passing
a `String` variable to these initializers avoids localization, which is
usually appropriate when the variable contains a user-provided value.

As a general rule, use a string literal argument when you want
localization, and a string variable argument when you don’t. In the case
where you want to localize the value of a string variable, use the string to
create a new `LocalizedStringKey` instance.

The following example shows how to create [`Text`](/documentation/SwiftUI/Text) instances both
with and without localization. The title parameter provided to the
[`Section`](/documentation/SwiftUI/Section) is a literal string, so SwiftUI creates a
`LocalizedStringKey` for it. However, the string entries in the
`messageStore.today` array are `String` variables, so the [`Text`](/documentation/SwiftUI/Text) views
in the list use the string values verbatim.

```
List {
    Section(header: Text("Today")) {
        ForEach(messageStore.today) { message in
            Text(message.title)
        }
    }
}
```

If the app is localized into Japanese with the following
translation of its `Localizable.strings` file:

```other
"Today" = "今日";
```

When run in Japanese, the example produces a
list like the following, localizing “Today” for the section header, but not
the list items.

![A list with a single section header displayed in Japanese.](images/com.apple.SwiftUI/SwiftUI-LocalizedStringKey-Today-List-Japanese@2x.png)

## Topics

### Creating a key from a literal value

[`init(_:)`](/documentation/SwiftUI/LocalizedStringKey/init(_:))

Creates a localized string key from the given string value.

[`init(stringLiteral:)`](/documentation/SwiftUI/LocalizedStringKey/init(stringLiteral:))

Creates a localized string key from the given string literal.

### Creating a key from an interpolation

[`init(stringInterpolation:)`](/documentation/SwiftUI/LocalizedStringKey/init(stringInterpolation:))

Creates a localized string key from the given string interpolation.

[`LocalizedStringKey.StringInterpolation`](/documentation/SwiftUI/LocalizedStringKey/StringInterpolation)

Represents the contents of a string literal with interpolations
while it’s being built, for use in creating a localized string key.



---

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)
