SwiftUI: AttributedString Localization does not seem to work
I have this test code
import SwiftUI
struct TestAppleSuggestion: View {
@Environment(\.locale) var locale: Locale
var body: some View {
VStack {
VStack {
Text("locale: \(locale.identifier)")
Text(AttributedString(localized: LocalizedStringResource(
"welcome",
locale: locale
)))
Text(AttributedString(localized:
"welcome",
locale: locale
))
}
}
}
}
#Preview {
TestAppleSuggestion().environment(\.locale, Locale(identifier: "fr-CA"))
}
Heres what I see in SwiftUi Preview

As you can see, applying the locale to LocalizedStringResource works but directly to the AttributedString does not.
I am confused why localization is working for some api and not other.
I would like to just apply localization directly to AttributedString as I don't actually need the LocalizationStringResource.