Contents

init(localized:including:)

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

Declaration

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

Parameters

  • resource:

    A 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 prior to calling this method if you want to localize this string in a different locale than the process that created the LocalizedStringResource.

The attributed string contains attributes of type AttributeScopes.FoundationAttributes.LocalizedStringArgumentAttributes to indicate runs containing formatted text, such as localized numbers or dates. Access these attributes with the attribute key localizedNumericArgument or localizedDateArgument.

See Also

Creating a Localized Attributed String