I’ve the next string
"shop_buy_now_marketing_template" = "BUY now inside 2 hours to obtain this particular <B>%1$d%% off</B> low cost.";
I render it as HTML utilizing the next code.
let rawString = "shop_buy_now_marketing_template".localized(low cost)
let htmlTemplate = """
<!doctype html>
<html>
<head>
<type>
physique {
font-family: -apple-system;
font-size: 17px;
}
</type>
</head>
<physique>
(rawString)
</physique>
</html>
"""
if let htmlData = htmlTemplate.knowledge(utilizing: .utf8) {
if let attributedString = attempt? NSAttributedString(knowledge: htmlData, choices: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) {
buyNowMarketingDescriptionLabel.attributedText = attributedString
}
}
The rendering seems good.
Nonetheless, if I’m utilizing non English
"shop_buy_now_marketing_template" = "立即在 2 小時內購買可享受 <B>%1$d%%</B> 的特別折扣。";
I get
Do you will have any concept how I can repair this? I want to render non English string to HTML attributed string.