<!--
{
  "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/AttributedString/init(localized:defaultValue:options:table:bundle:locale:comment:including:)-9gjtg",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation16AttributedStringV9localized12defaultValue7options5table6bundle6locale7comment9includingACs06StaticC0V_SSAAE012LocalizationF0VAC17FormattingOptionsVSSSgSo8NSBundleCSgAA6LocaleVSgAMSgs7KeyPathCyAA15AttributeScopesOxmGtcAA0U5ScopeRzlufc"
  },
  "title" : "init(localized:defaultValue:options:table:bundle:locale:comment:including:)"
}
-->

# init(localized:defaultValue:options:table:bundle:locale:comment:including:)

Creates an attributed string by looking up a localized string from the app’s bundle, including an attribute scope that a key path identifies, using a default value if necessary.

```
init<S>(localized key: StaticString, defaultValue: String.LocalizationValue, options: AttributedString.FormattingOptions = [], table: String? = nil, bundle: Bundle? = nil, locale: Locale? = nil, comment: StaticString? = nil, including scope: KeyPath<AttributeScopes, S.Type>) where S : AttributeScope
```

## Parameters

`key`

The key for a string in the table that `table` identifies.

`defaultValue`

The localized string for the development locale. For other locales, the string uses this value if a localized string for `key` isn’t found in the table.

`options`

Options that affect the handling of attributes.

`table`

The bundle’s string table to search. If `table` is `nil` or is an empty string, the method attempts to use the table in `Localizable.strings`. The default is `nil`.

`bundle`

The bundle to use for looking up strings. If `nil`, an app searches its main bundle. The default is `nil`.

`locale`

The locale of the localized string to retrieve. If `nil`, this initializer uses the current locale. The default is `nil`.

`comment`

The comment to place above the key-value pair in the strings file. This parameter provides the translator with some context about the localized string’s presentation to the user.

`scope`

An [`AttributeScopes`](/documentation/Foundation/AttributeScopes) key path that identifies an attribute scope to associate with the attributed string.

## Discussion

Use this initializer instead of [`init(localized:options:table:bundle:locale:comment:including:)`](/documentation/Foundation/AttributedString/init(localized:options:table:bundle:locale:comment:including:)-5jzpg) if you prefer to use a symbolic string key, rather than use the development language’s string as the 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)