<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/AttributedString/init(localized:including:)-2xebo",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation16AttributedStringV9localized9includingAcA09LocalizedC8ResourceV_xmtcAA14AttributeScopeRzlufc"
  },
  "title" : "init(localized:including:)"
}
-->

# init(localized:including:)

Creates a localized attributed string from a localized string resource, including an attribute scope.

```
init<S>(localized resource: LocalizedStringResource, including scope: S.Type) where S : AttributeScope
```

## Parameters

`resource`

A [`LocalizedStringResource`](/documentation/Foundation/LocalizedStringResource) that provides the localization key, table, bundle, and locale.

`scope`

An attribute scope to associate with the attributed string.

## Discussion

Call this initializer to look up the localization indicated by `resource`. Alter the resource’s [`locale`](/documentation/Foundation/LocalizedStringResource/locale) prior to calling this method if you want to localize this string in a different locale than the process that created the [`LocalizedStringResource`](/documentation/Foundation/LocalizedStringResource).

The attributed string contains attributes of type [`AttributeScopes.FoundationAttributes.LocalizedStringArgumentAttributes`](/documentation/Foundation/AttributeScopes/FoundationAttributes/LocalizedStringArgumentAttributes-swift.struct) to indicate runs containing formatted text, such as localized numbers or dates. Access these attributes with the attribute key [`localizedNumericArgument`](/documentation/Foundation/AttributeScopes/FoundationAttributes/LocalizedStringArgumentAttributes-swift.struct/localizedNumericArgument) or [`localizedDateArgument`](/documentation/Foundation/AttributeScopes/FoundationAttributes/LocalizedStringArgumentAttributes-swift.struct/localizedDateArgument).

---

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)