SwiftUI Accessibility Language
When creating a language learning app with SwiftUI, VoiceOver may not pronounce text correctly if it's in a different language than the device's locale. To fix this, you need to change the accessibility language used by VoiceOver. In UIKit, you can set the accessibilityLanguage property on text labels, but this is not available in SwiftUI. One suggested solution is to use AttributedString with the accessibilitySpeechLanguage attribute, but this does not work. Another solution is to change the locale environment for each view using the environment modifier. However, this only works if you use the verbatim initializer for the Text view, as it treats the text as a localized string key by default. This solution works for Text views, but requires a longer form for views like Label. You can apply the locale to the label or the child text view, but if you use a Label with an icon, the locale only takes effect when applied to the Button. This means VoiceOver will pronounce "button" in the modified locale, but the main text will be pronounced correctly. Overall, changing the locale environment for each view is the solution to change the accessibility language used by VoiceOver in SwiftUI.