3

I have a few Text("dummy") within SwiftUI previews. Every time I perform export localizations, these would get exported. Is there any way to manually mark them as "do not localize"?

Ben Lu
  • 2,982
  • 4
  • 31
  • 54
  • Does this answer your question? [Difference between Text("") and Text(verbatim: "") initializers in SwiftUI](https://stackoverflow.com/questions/56505679/difference-between-text-and-textverbatim-initializers-in-swiftui) – George Dec 26 '21 at 17:02

2 Answers2

7

Use with verbatim constructor, like

Text(verbatim: "dummy")
Asperi
  • 228,894
  • 20
  • 464
  • 690
0

Convenient way to use keep always safe and get rid of Text() localisation globally. It will override the default init and get rid of localisation.

extension Text {
    public init<S>(_ content: S) where S : StringProtocol {
        self.init(verbatim: String(content))
    }
}
bodich
  • 1,708
  • 12
  • 31