beyondtao / gitalk

0 stars 0 forks source link

Why does string localization/internationalization not work in SwiftUI #3

Open beyondtao opened 1 year ago

beyondtao commented 1 year ago

https://blog.iostao.com/2022/09/swiftui-string-localization-notwork/

struct TabItem: Identifiable { var id = UUID() var name: String var icon: String var tab: TabEnum } var tabItems = [ TabItem(name: "home", icon: "house", tab: .home), ] ForEach(tabItems) { item in // string localizable not working in here // item.name is "home" Text(item.name) // but if write code like this, it's ok Text("home") } It has been proved that if a string in Text(“home) is passed as a text, it can only be interpreted as a localized keyword.