2023 Accessibility & InclusionSwiftUI & UI Frameworks
WWDC23 · 18 min · Accessibility & Inclusion / SwiftUI & UI Frameworks
Unlock the power of grammatical agreement
Discover how you can use automatic grammatical agreement in your apps and games to create inclusive and more natural-sounding expressions. We’ll share best practices for working with Foundation, showcase examples in multiple languages, and demonstrate how to use these APIs to enhance the user experience for your apps. For an introduction to automatic grammatical agreement, watch “What’s new in Foundation” from WWDC21.
Watch at developer.apple.com ↗Chapters
Code shown on screen · 2 snippets
agreeWithConcept
// Formatting the string
var options = AttributedString.LocalizationOptions()
options.concepts = [.localizedPhrase(food.localizedName)]
let size = AttributedString(localized: "small", options: options) Preferred terms of address
// A person who is delivering the food order
struct DeliveryPerson {
// The person's preferred name
var name: String
// An avatar for the delivery person
var avatar: Image
// The person's preferred terms of address. This list may contain more than
// one option, we will use the first applicable one for the language that's
// used in the UI.
var preferredTermsOfAddress: [TermOfAddress]
}
// Formatting the message in Swift
var options = AttributedString.LocalizationOptions()
options.concepts = [.termsOfAddress(person.preferredTermsOfAddress)]
let message = AttributedString(localized:
"\(person.name) is on ^[their](referentConcept: 1) way.”, options: options) Resources
Related sessions
-
32 min -
22 min -
38 min