SwiftUI didn't translate the string in variable.
I have added:
"Name" = "姓名";
if I wrote:
Text("Name")
works good. I can see the label with姓名
.
If I define a variable like:
@State var title = "Name"
Text(title)
Then the localization doesn't work. Still in Chinese. Any tips?
您必须明确指出您的title
变量是LocalizedStringKey
,而不是String
。
@State var title: LocalizedStringKey = "Name"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.