Localization changes layout and meaning, not just strings. Preserve placeholders and plural rules, then exercise long text, right-to-left presentation and missing translations.
- 1Source string
- 2Context and placeholders
- 3Translation review
- 4Layout checks
Work through the example
Give the agent the screen context for each string. Compare accessibility labels and visible labels after translation.
Start with a disposable branch and synthetic data. Write the expected outcome before changing the implementation, then keep the first failing result. This prevents a later repair from quietly redefining the task. The procedure below is grounded in the repository reference; its examples must still be checked against your project and installed toolchain.
Implementation reference
The following focused section is adapted from the maintained project guide. It preserves the source’s examples and limitations.
6. Localization Approach
String Catalogs Setup
All user-facing strings must use String(localized:). Never hardcode display text.
Xcode creates a Localizable.xcstrings file (String Catalog) that automatically extracts strings.
// MARK: - Correct: Localized Strings
let title = String(localized: "welcome.title")
let message = String(localized: "welcome.message")
// With default value
let greeting = String(localized: "greeting", defaultValue: "Hello there!")
// MARK: - String Interpolation
let itemCount = 5
let label = String(localized: "\(itemCount) items remaining")
// MARK: - Pluralization (handled in .xcstrings catalog)
// In the String Catalog, define plural variants:
// "item_count" -> one: "%lld item", other: "%lld items"
let countLabel = String(localized: "\(itemCount) items")
// MARK: - Table-based organization
let settingsTitle = String(localized: "title", table: "Settings")
Date and Number Formatting
// MARK: - Locale-Aware Formatting
struct FormattingExamples: View {
let price: Decimal = 49.99
let eventDate = Date()
let progress = 0.756
var body: some View {
VStack(alignment: .leading) {
// Currency — adapts to user locale
Text(price, format: .currency(code: "USD"))
// Date — adapts to locale conventions
Text(eventDate, format: .dateTime.month(.wide).day().year())
// Relative date
Text(eventDate, format: .relative(presentation: .named))
// Percentage
Text(progress, format: .percent.precision(.fractionLength(1)))
// Measurement
Text(Measurement(value: 72, unit: UnitTemperature.fahrenheit),
format: .measurement(width: .abbreviated))
}
}
}
RTL and Layout Considerations
// MARK: - RTL-Safe Layout
struct RTLSafeView: View {
@Environment(\.layoutDirection) var layoutDirection
var body: some View {
HStack {
// Use .leading/.trailing, never .left/.right
Image(systemName: "arrow.forward")
.flipsForRightToLeftLayoutDirection(true)
Text(String(localized: "next"))
}
.frame(maxWidth: .infinity, alignment: .leading) // Flips automatically in RTL
}
}
Acceptance and failure review
| Checkpoint | What to inspect | If it does not match |
|---|---|---|
| Source string | Confirm the input and environment | Preserve the failure and return to this step |
| Context and placeholders | Inspect the intermediate artifact | Preserve the failure and return to this step |
| Translation review | Run the focused check | Preserve the failure and return to this step |
| Layout checks | Record the observed result | Preserve the failure and return to this step |
Ask the agent to explain the smallest change that resolves the observed mismatch. Keep unrelated refactors out of the repair. A change that makes a warning disappear is not enough if the behavior or ownership contract has changed. Re-run the same acceptance check so the before and after results are comparable.
Evidence and limits
Machine-generated translations still need language review; no multi-language audit is claimed.
This is an educational guide. Its presence in the series does not certify a completed client-specific lab. The series evidence record separates executed checks from exercises and blocked environments.
Inspect the source used in this lesson.
Related reading
- SwiftUI: review state transitions before polishing the screen
Make loading, empty, success and error states part of the implementation brief.
- Five checks for an AI-built SwiftUI app
Use persistence, search and accessible states to make “it works” a testable claim.
What to do next
Next: App icons in 2026: Liquid Glass, Icon Composer, and generating them from SVG layers