SwiftUI Text Patterns Reference
SwiftUI Text Patterns Reference
Section titled “SwiftUI Text Patterns Reference”Table of Contents
Section titled “Table of Contents”Text Initialization: Verbatim vs Localized
Section titled “Text Initialization: Verbatim vs Localized”Default: always use Text("…"). Only use Text(verbatim:) when explicitly required for a string literal that must not be localized.
// Localized literal - "Save" is used as the localization key and looked up in Localizable.strings (only if one exists in the project)Text("Save")
// String variable - bypasses localization automatically; no verbatim neededlet filename: String = model.exportFilenameText(filename)
// Non-localized literal - use verbatim only when the literal must not be localizedText(verbatim: "pencil")Decision Flow
Section titled “Decision Flow”Is the input a String variable or dynamic value?└─ YES → Text(variable) // bypasses localization automatically
Is the string literal intended for localization?├─ YES → Text("…") // default; key looked up in Localizable.strings└─ NO → Text(verbatim: "…") // only when explicitly non-localized