$npx -y skills add johnrogers/claude-swift-engineering --skill localizationUse when implementing internationalization (i18n), String Catalogs, pluralization, or right-to-left layout support. Covers modern localization workflows with Xcode String Catalogs and LocalizedStringKey patterns.
| 1 | # Localization |
| 2 | |
| 3 | Modern iOS localization using String Catalogs (.xcstrings) for managing translations, plural forms, and locale-aware content. Supports SwiftUI's LocalizedStringKey and String(localized:) APIs. |
| 4 | |
| 5 | ## Reference Loading Guide |
| 6 | |
| 7 | **ALWAYS load reference files if there is even a small chance the content may be required.** It's better to have the context than to miss a pattern or make a mistake. |
| 8 | |
| 9 | | Reference | Load When | |
| 10 | |-----------|-----------| |
| 11 | | **[String Catalogs](references/string-catalogs.md)** | Setting up or using Xcode 15+ String Catalogs | |
| 12 | | **[Pluralization](references/pluralization.md)** | Handling plural forms, stringsdict migration | |
| 13 | | **[Formatting](references/formatting.md)** | Date, number, currency locale-aware formatting | |
| 14 | | **[RTL Support](references/rtl-support.md)** | Right-to-left layouts, semantic directions | |
| 15 | |
| 16 | ## Core Workflow |
| 17 | |
| 18 | 1. Create String Catalog in Xcode (File > New > String Catalog) |
| 19 | 2. Mark strings with `String(localized:comment:)` or use SwiftUI's automatic extraction |
| 20 | 3. Add plural variants in String Catalog editor where needed |
| 21 | 4. Test with pseudo-localization (Scheme > Run > Options > App Language) |
| 22 | 5. Export for translation (File > Export Localizations) |
| 23 | |
| 24 | ## Key Patterns |
| 25 | |
| 26 | ```swift |
| 27 | // SwiftUI - automatic localization |
| 28 | Text("Welcome") |
| 29 | Button("Continue") { } |
| 30 | |
| 31 | // Explicit localization with context |
| 32 | let title = String(localized: "Settings", comment: "Navigation title") |
| 33 | |
| 34 | // Deferred localization for custom views |
| 35 | struct CardView: View { |
| 36 | let title: LocalizedStringResource |
| 37 | var body: some View { Text(title) } |
| 38 | } |
| 39 | ``` |
| 40 | |
| 41 | ## Build Settings |
| 42 | |
| 43 | - **Use Compiler to Extract Swift Strings**: Yes |
| 44 | - **Localization Prefers String Catalogs**: Yes |
| 45 | |
| 46 | ## Common Mistakes |
| 47 | |
| 48 | 1. **Forgetting String Catalog in Build Phases** — Adding String Catalog but forgetting to check "Localize" in File Inspector means it's not embedded. Always verify in Build Phases > Copy Bundle Resources. |
| 49 | |
| 50 | 2. **Pseudo-localization not tested** — Not running your app with pseudo-localization (German/Chinese pseudo-locale) means you miss text overflow and RTL issues. Always test with pseudo-localization before translation. |
| 51 | |
| 52 | 3. **Hardcoded strings anywhere** — Even one hardcoded string outside the String Catalog breaks extraction and automation. Use `String(localized:)` everywhere or use `LocalizedStringResource` for deferred localization. |
| 53 | |
| 54 | 4. **Context loss in translations** — Providing no comment for translators means they guess context and get it wrong. Add comments explaining where the string appears and what it means. |
| 55 | |
| 56 | 5. **RTL layouts not tested** — Assuming LTR layout works for RTL languages (Arabic, Hebrew) fails miserably. Test with system language set to Arabic and verify semantic directions are used. |