Post

Replies

Boosts

Views

Activity

Reply to iOS ImageRenderer Unable to localize text correctly Bug
Code: VStack(spacing: 8) { // The normal view let simpleView = VStack() { Text("连续生存") Text("总打卡天数") Text("\(0) days") Text("\(1) days") Text("\(2) days") } .padding(4) .background(Color.gray) simpleView // The normal view, language is Chinese simpleView // "\(1) days" is correctly converted to "1 day". .environment(\.locale, .init(identifier: "en")) // After converting to UIImage with ImageRenderer, the text becomes English, it should be Simplified Chinese. // and "\(1) days" is not converted to "1 day". let image: UIImage = ImageRenderer(content: simpleView).uiImage ?? UIImage(named: "error.image")! Image(uiImage: image) } .environment(\.locale, .init(identifier: "zh-Hans")) // Language set to Simplified Chinese Localizable.strings:
 "总打卡天数" = "Total Check-ins"; "连续生存" = "Streak"; Localizable.stringsdict: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>%lld days</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@Variable@</string> <key>Variable</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>lld</string> <key>other</key> <string>%lld days</string> <key>one</key> <string>1 day</string> <key>zero</key> <string>0 day</string> </dict> </dict> </dict> </plist>
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24
Reply to iOS ImageRenderer Unable to localize text correctly Bug
Code: VStack(spacing: 8) { // The normal view let simpleView = VStack() { Text("连续生存") Text("总打卡天数") Text("\(0) days") Text("\(1) days") Text("\(2) days") } .padding(4) .background(Color.gray) simpleView // The normal view, language is Chinese simpleView // "\(1) days" is correctly converted to "1 day". .environment(\.locale, .init(identifier: "en")) // After converting to UIImage with ImageRenderer, the text becomes English, it should be Simplified Chinese. // and "\(1) days" is not converted to "1 day". let image: UIImage = ImageRenderer(content: simpleView).uiImage ?? UIImage(named: "error.image")! Image(uiImage: image) } .environment(\.locale, .init(identifier: "zh-Hans")) // Language set to Simplified Chinese Localizable.strings:
 "总打卡天数" = "Total Check-ins"; "连续生存" = "Streak"; Localizable.stringsdict: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>%lld days</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@Variable@</string> <key>Variable</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>lld</string> <key>other</key> <string>%lld days</string> <key>one</key> <string>1 day</string> <key>zero</key> <string>0 day</string> </dict> </dict> </dict> </plist>
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to iOS ImageRenderer Unable to localize text correctly Bug
Regardless of the language, when using ImageRenderer, it will be converted to English incorrectly.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’24