---
title: LocalizedStringKey
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/localizedstringkey
---

# LocalizedStringKey

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

## Declaration

```swift
@frozen struct LocalizedStringKey
```

## Mentioned in

Adding a search interface to your app Preparing views for localization

## Overview

Overview Initializers for several SwiftUI types – such as Text, Toggle, 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 ExpressibleByStringLiteral. Types whose initializers take a LocalizedStringKey usually have a corresponding initializer that accepts a parameter that conforms to 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 instances both with and without localization. The title parameter provided to the 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 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: "Today" = "今日"; When run in Japanese, the example produces a list like the following, localizing “Today” for the section header, but not the list items.

## Topics

### Creating a key from a literal value

- [init(_:)](swiftui/localizedstringkey/init(_:).md)
- [init(stringLiteral:)](swiftui/localizedstringkey/init(stringliteral:).md)

### Creating a key from an interpolation

- [init(stringInterpolation:)](swiftui/localizedstringkey/init(stringinterpolation:).md)
- [LocalizedStringKey.StringInterpolation](swiftui/localizedstringkey/stringinterpolation.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [ExpressibleByExtendedGraphemeClusterLiteral](swift/expressiblebyextendedgraphemeclusterliteral.md)
- [ExpressibleByStringInterpolation](swift/expressiblebystringinterpolation.md)
- [ExpressibleByStringLiteral](swift/expressiblebystringliteral.md)
- [ExpressibleByUnicodeScalarLiteral](swift/expressiblebyunicodescalarliteral.md)

## See Also

### Localizing text

- [Preparing views for localization](swiftui/preparing-views-for-localization.md)
- [locale](swiftui/environmentvalues/locale.md)
- [typesettingLanguage(_:isEnabled:)](swiftui/view/typesettinglanguage(_:isenabled:).md)
- [TypesettingLanguage](swiftui/typesettinglanguage.md)
