Swift Localization Patterns
Use this skill for multilingual Swift and SwiftUI work with a bias toward modern Apple localization workflows. Assume the goal is not only translating strings, but keeping keys, formatting, grammar, and UI behavior correct across many locales.
Delivery Workflow
Use the checklist below and track progress:
Swift localization progress:
- [ ] Step 1: Discover the current localization assets and project convention
- [ ] Step 2: Define key strategy and translator context
- [ ] Step 3: Implement localized strings, pluralization, and formatting
- [ ] Step 4: Verify multi-locale UI behavior
- [ ] Step 5: Review missing translations, fallbacks, and regressions
Project Assumptions
- Prefer the repository's existing localization mechanism first.
- If the project is already on modern Apple localization workflows, prefer String Catalogs (
.xcstrings).
- If the project still uses
Localizable.strings or related legacy resources, stay consistent unless the task explicitly includes migration.
- Do not mix multiple localization strategies inside one feature without a reason.
Keys and Source Strategy
- Keep one clear convention for how translatable content is identified.
- Reuse the project's existing key style:
- semantic keys if the codebase uses them
- source-string keys if the codebase already relies on them
- Keep keys stable; changing them casually creates unnecessary translation churn.
- Add translator-facing context when the meaning is ambiguous.
- Keep domain-specific strings grouped coherently by feature, screen, or table where the project pattern supports it.
Localized Access Patterns
- Use localized APIs intentionally instead of hardcoding user-facing copy.
- Distinguish localized text from verbatim/debug/internal strings.
- Keep the UI layer declarative: localized display strings in views, business meaning in models and services.
- Prefer explicit localized resources for non-UI strings that are reused or passed across layers.
- Avoid hiding localization lookups inside random helpers where call sites lose meaning.
Interpolation, Plurals, and Grammar
- Do not build sentences by concatenating translated fragments.
- Prefer placeholders and localized templates that allow word order to change across languages.
- Model pluralization explicitly; do not fake it with simple singular/plural conditionals when the language rules are richer.
- Keep gender, case, and grammar-sensitive phrases explicit when the product domain requires them.
- Preserve translator context for placeholders so the sentence can be translated correctly.
Locale-Aware Formatting
- Use locale-aware formatting for dates, numbers, currency, measurements, and lists.
- Prefer system format styles or established project helpers over manual string formatting.
- Keep locale-sensitive formatting close to the presentation layer unless a shared formatter abstraction already exists.
- Ensure placeholder values remain compatible with the locale in which they are shown.
Multi-Locale UI Verification
- Verify long strings, truncated text, and wrapped layouts.
- Check right-to-left behavior when the app supports RTL languages.
- Validate Dynamic Type together with localization because long strings amplify layout weaknesses.
- Use previews, runtime locale switching, or test fixtures to verify multiple locales intentionally.
- Watch for clipped buttons, collapsed rows, misaligned icons, and broken navigation titles.
SwiftUI and Modern Apple Guidance
- Prefer the project's current SwiftUI localization pattern for
Text and related UI labels.
- Use
Text(verbatim:) only for truly non-localized content.
- For preview and verification flows, test representative locales such as:
- source language
- one long-text language
- one RTL language if supported
- Keep localized resources compatible with the iOS 17+ stack already assumed in this repository.
Translation Review Checklist
Coverage:
- [ ] New user-facing strings are localizable
- [ ] Existing keys are reused where appropriate
- [ ] Missing translations and accidental hardcoded strings are checked
Correctness:
- [ ] Plurals and placeholders are modeled intentionally
- [ ] Dates, numbers, and similar values are locale-aware
- [ ] Translator context exists where meaning is ambiguous
UX:
- [ ] Long strings and RTL behavior are verified where relevant
- [ ] Layout survives localization and Dynamic Type together
- [ ] Fallback behavior is understood and acceptable
Anti-Patterns to Avoid
| Anti-Pattern |
Instead Do |
| Hardcoded user-facing copy in Swift code |
Route it through the project's localization system |
| Concatenating translated fragments into sentences |
Use localized templates with placeholders |
| Changing key style per screen |
Follow one project-wide convention |
| Manual date/number formatting for UI |
Use locale-aware formatting |
| Treating localization as string replacement only |
Verify grammar, layout, RTL, and fallback behavior |
| Using non-localized text APIs for translatable content |
Use explicit localized APIs and reserve verbatim text for true literals |
Omitting bundle: in a Swift package or framework (lookup silently hits Bundle.main) |
Pass bundle: #bundle to Text/Label/Button and LocalizedStringResource |
Using .left/.right edges or alignment |
Use .leading/.trailing so RTL mirrors correctly |
| Interpolated strings without translator context |
Add a comment: describing each placeholder |
Plain String for localizable text on non-view types |
Carry LocalizedStringResource and resolve it at the view |
Connected Skills
swiftui-specialist - Apple's references/localization.md covers bundle selection, LocalizedStringResource, format styles, and translator comments; follow it on conflicts
swiftui - use for SwiftUI view structure, MVVM, Observation, and UI verification context
technical-context-discovery - follow project localization and iOS conventions before editing
ui-verification - validate layout and visual behavior across locales when UI output matters
1---2name: swift-localization3description: Swift localization and internationalization patterns for multilingual Apple-platform apps. Use when Codex needs to build, refactor, debug, or review String Catalogs, localized SwiftUI text, `String(localized:)` usage, pluralization, locale-aware formatting, right-to-left behavior, or translation workflows across many languages in a Swift or SwiftUI codebase.4metadata:5 source: https://skillmd.com/skills/jakubmikolajek/swift-localization6---78# Swift Localization Patterns910Use this skill for multilingual Swift and SwiftUI work with a bias toward modern Apple localization workflows. Assume the goal is not only translating strings, but keeping keys, formatting, grammar, and UI behavior correct across many locales.1112## Delivery Workflow1314Use the checklist below and track progress:1516```17Swift localization progress:18- [ ] Step 1: Discover the current localization assets and project convention19- [ ] Step 2: Define key strategy and translator context20- [ ] Step 3: Implement localized strings, pluralization, and formatting21- [ ] Step 4: Verify multi-locale UI behavior22- [ ] Step 5: Review missing translations, fallbacks, and regressions23```2425## Project Assumptions2627- Prefer the repository's existing localization mechanism first.28- If the project is already on modern Apple localization workflows, prefer String Catalogs (`.xcstrings`).29- If the project still uses `Localizable.strings` or related legacy resources, stay consistent unless the task explicitly includes migration.30- Do not mix multiple localization strategies inside one feature without a reason.3132## Keys and Source Strategy3334- Keep one clear convention for how translatable content is identified.35- Reuse the project's existing key style:36 - semantic keys if the codebase uses them37 - source-string keys if the codebase already relies on them38- Keep keys stable; changing them casually creates unnecessary translation churn.39- Add translator-facing context when the meaning is ambiguous.40- Keep domain-specific strings grouped coherently by feature, screen, or table where the project pattern supports it.4142## Localized Access Patterns4344- Use localized APIs intentionally instead of hardcoding user-facing copy.45- Distinguish localized text from verbatim/debug/internal strings.46- Keep the UI layer declarative: localized display strings in views, business meaning in models and services.47- Prefer explicit localized resources for non-UI strings that are reused or passed across layers.48- Avoid hiding localization lookups inside random helpers where call sites lose meaning.4950## Interpolation, Plurals, and Grammar5152- Do not build sentences by concatenating translated fragments.53- Prefer placeholders and localized templates that allow word order to change across languages.54- Model pluralization explicitly; do not fake it with simple singular/plural conditionals when the language rules are richer.55- Keep gender, case, and grammar-sensitive phrases explicit when the product domain requires them.56- Preserve translator context for placeholders so the sentence can be translated correctly.5758## Locale-Aware Formatting5960- Use locale-aware formatting for dates, numbers, currency, measurements, and lists.61- Prefer system format styles or established project helpers over manual string formatting.62- Keep locale-sensitive formatting close to the presentation layer unless a shared formatter abstraction already exists.63- Ensure placeholder values remain compatible with the locale in which they are shown.6465## Multi-Locale UI Verification6667- Verify long strings, truncated text, and wrapped layouts.68- Check right-to-left behavior when the app supports RTL languages.69- Validate Dynamic Type together with localization because long strings amplify layout weaknesses.70- Use previews, runtime locale switching, or test fixtures to verify multiple locales intentionally.71- Watch for clipped buttons, collapsed rows, misaligned icons, and broken navigation titles.7273## SwiftUI and Modern Apple Guidance7475- Prefer the project's current SwiftUI localization pattern for `Text` and related UI labels.76- Use `Text(verbatim:)` only for truly non-localized content.77- For preview and verification flows, test representative locales such as:78 - source language79 - one long-text language80 - one RTL language if supported81- Keep localized resources compatible with the iOS 17+ stack already assumed in this repository.8283## Translation Review Checklist8485```86Coverage:87- [ ] New user-facing strings are localizable88- [ ] Existing keys are reused where appropriate89- [ ] Missing translations and accidental hardcoded strings are checked9091Correctness:92- [ ] Plurals and placeholders are modeled intentionally93- [ ] Dates, numbers, and similar values are locale-aware94- [ ] Translator context exists where meaning is ambiguous9596UX:97- [ ] Long strings and RTL behavior are verified where relevant98- [ ] Layout survives localization and Dynamic Type together99- [ ] Fallback behavior is understood and acceptable100```101102## Anti-Patterns to Avoid103104| Anti-Pattern | Instead Do |105|---|---|106| Hardcoded user-facing copy in Swift code | Route it through the project's localization system |107| Concatenating translated fragments into sentences | Use localized templates with placeholders |108| Changing key style per screen | Follow one project-wide convention |109| Manual date/number formatting for UI | Use locale-aware formatting |110| Treating localization as string replacement only | Verify grammar, layout, RTL, and fallback behavior |111| Using non-localized text APIs for translatable content | Use explicit localized APIs and reserve verbatim text for true literals |112| Omitting `bundle:` in a Swift package or framework (lookup silently hits `Bundle.main`) | Pass `bundle: #bundle` to `Text`/`Label`/`Button` and `LocalizedStringResource` |113| Using `.left`/`.right` edges or alignment | Use `.leading`/`.trailing` so RTL mirrors correctly |114| Interpolated strings without translator context | Add a `comment:` describing each placeholder |115| Plain `String` for localizable text on non-view types | Carry `LocalizedStringResource` and resolve it at the view |116117## Connected Skills118119- `swiftui-specialist` - Apple's `references/localization.md` covers bundle selection, `LocalizedStringResource`, format styles, and translator comments; follow it on conflicts120- `swiftui` - use for SwiftUI view structure, MVVM, Observation, and UI verification context121- `technical-context-discovery` - follow project localization and iOS conventions before editing122- `ui-verification` - validate layout and visual behavior across locales when UI output matters