Overview of XCStrings Tool
mainXCStrings Tool is a plugin designed to help developers use Xcode 15's .xcstrings (Strings Catalog) format as the single source of truth for localized strings.
Instead of defining localized strings directly within your Swift views (which can lead to boilerplate and messy code), you define them in a Strings Catalog. The tool then generates Swift source code that allows you to access these strings using type-safe, dot-syntax properties.
Key benefits include:
- Concise Views: Removes localized string definitions from UI code.
- No Boilerplate: Eliminates the need to manually maintain string constant files.
- Comment Reuse: Automatically turns translator comments from the catalog into inline Swift documentation.
- Legacy Support: Can also generate Swift code for projects using legacy
.stringsand.stringsdictformats.
// Before: Manual string definitions in views
Text(
"You've seen \(dogs.count) dogs with a combined rating of \(totalRating)/\(dogs.count * 10)",
bundle: .module,
comment: "Summary of sightings shown at the bottom of the list"
)
// After: Using generated type-safe code
Text(.localizable.contentSummary(dogs.count, totalRating, dogs.count * 10))