Ben Lu
Ben Lu

Reputation: 3042

Prevent Text("string") from being exported as localization

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"?

Upvotes: 7

Views: 987

Answers (2)

bodich
bodich

Reputation: 2215

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))
    }
}

Upvotes: -1

Asperi
Asperi

Reputation: 258087

Use with verbatim constructor, like

Text(verbatim: "dummy")

Upvotes: 16

Related Questions