最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

swift - How to get localised String from LocalizedStringKey - Stack Overflow

programmeradmin0浏览0评论

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 = "
发布评论

评论列表(0)

  1. 暂无评论