admin管理员组

文章数量:1335554

I'm curious, does anyone know what the steps are to get from a LocalizedStringKey to a normal String in Swift? There are plenty of resources on the results of feeding in a LocalizedStringKey to SwiftUI initialisers, but I can't find anything that lets you reproduce the inner workings of SwiftUI to do the localization.

For example, consider the following code:

private func localize(_ key: LocalizedStringKey) -> String {
    // This is the part that I need
    return "Bonjour"
}

struct Greeter: View {
    var greetingKey: LocalizedStringKey
    var body: some View {
        let localGreeting = localize(greetingKey)
        let modifiedGreeting = "

本文标签: swiftHow to get localised String from LocalizedStringKeyStack Overflow