gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.26k stars 267 forks source link

Localization Support? #40

Closed thatvirtualboy closed 1 year ago

thatvirtualboy commented 3 years ago

Hi there, thank you for making this. I've noticed it doesn't appear to work with Localization. The strings aren't read in the Localizable.strings files since they're not Text() but rather Markdown ()

Any ways around this?

gonzalezreal commented 3 years ago

Sorry for the late response. MarkdownUI does not support LocalizedStringKey at the moment, but I might consider adding support in the future. As a workaround, you can use the good old NSLocalizedString:

Markdown(NSLocalizedString("yourLocalizedStringKey", comment: ""))
SF-Simon commented 3 years ago

I also need this function.

At present, I read the String file according to the language, and then directly pass the parameters to the Markdown method. If there is a better idea, it should be realized as soon as possible. thank you

PS:

I like this open source project very much and hope to stick to it. Thank you for your contribution to open source. Thank you very much

gonzalezreal commented 3 years ago

Unfortunately, I can't add support for LocalizedStringKey because its properties are not accessible. Maybe Apple opens this API in a future SwiftUI release. For the moment, we have to stick to the workaround that I mentioned previously.