Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Reviews, improves, and writes SwiftUI code following state management, view composition, performance, and iOS 26+ Liquid Glass best practices.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/text-patterns.md
1# SwiftUI Text Patterns Reference23> For broader localization guidance — String Catalogs, `#bundle` for packages, `LocalizedStringResource`, locale-aware formatting, RTL layout, and translator comments — see `references/localization.md`. This file covers only the verbatim-vs-localized decision for a single `Text`.45## Table of Contents67- [Text Initialization: Verbatim vs Localized](#text-initialization-verbatim-vs-localized)89## Text Initialization: Verbatim vs Localized1011**Default: always use `Text("…")`.** Only use `Text(verbatim:)` when explicitly required for a string literal that must not be localized.1213```swift14// Localized literal - "Save" is used as the localization key and looked up in Localizable.strings (only if one exists in the project)15Text("Save")1617// String variable - bypasses localization automatically; no verbatim needed18let filename: String = model.exportFilename19Text(filename)2021// Non-localized literal - use verbatim only when the literal must not be localized22Text(verbatim: "pencil")23```2425### Decision Flow2627```28Is the input a String variable or dynamic value?29└─ YES → Text(variable) // bypasses localization automatically3031Is the string literal intended for localization?32├─ YES → Text("…") // default; key looked up in Localizable.strings33└─ NO → Text(verbatim: "…") // only when explicitly non-localized34```35