PluginBench
Skill
Pass
Audit score 90

ios-localization

dpearson2699/swift-ios-skills

Localize iOS/macOS apps with String Catalogs, generated symbols, and locale-aware formatting.

What is ios-localization?

Implement multi-language support and internationalization in iOS 15+ apps using String Catalogs (.xcstrings), generated localizable symbols (Xcode 26+), FormatStyle for locale-aware formatting, and RTL-aware layout. Use this skill when adding language support, setting up compile-time-safe localization keys, handling plurals, formatting dates/numbers/currencies, or ensuring UI works correctly in right-to-left languages.

  • Set up and manage String Catalogs (.xcstrings) for automatic string extraction and translation tracking
  • Enable generated Swift symbols (Xcode 26+) for compile-time-safe localization key access
  • Handle pluralization rules and device-specific string variations natively in catalogs
  • Format numbers, dates, currencies, and measurements for different locales using FormatStyle
  • Implement right-to-left (RTL) layout support for Arabic, Hebrew, and other RTL languages
  • Support Dynamic Type and locale-aware text rendering across iOS 15+ and macOS

How to install ios-localization

npx skills add https://github.com/dpearson2699/swift-ios-skills --skill ios-localization
Prerequisites
  • Xcode 15+ (for String Catalogs); Xcode 26+ for generated symbols
  • iOS 15+ deployment target (for String(localized:)); iOS 16+ for LocalizedStringResource
  • Basic understanding of SwiftUI or UIKit string handling
Claude Code
Cursor
Windsurf
Cline

How to use ios-localization

  1. 1.Create or open a Localizable.xcstrings file in Xcode (Build Settings > Localization > Generate String Catalog)
  2. 2.Use LocalizedStringKey (SwiftUI literals), String(localized:), or LocalizedStringResource in code; Xcode auto-extracts strings on build
  3. 3.Mark translations as Needs Review, Translated, or Stale in the String Catalog editor
  4. 4.Enable generated symbols (Build Settings > Generate String Catalog Symbols = Yes) and use camelCased key names like Text(.welcomeBack)
  5. 5.Apply FormatStyle for locale-aware formatting of dates, numbers, and measurements
  6. 6.Test RTL layout by running in Arabic or Hebrew locale and verify Dynamic Type scaling

Use cases

Good for
  • Adding multi-language support to a new iOS app using String Catalogs and generated symbols
  • Migrating legacy .strings/.stringsdict files to modern String Catalog workflow
  • Implementing plural forms (singular/plural/zero) for dynamic content like item counts
  • Formatting user-facing dates, numbers, and currency values for different locales and regions
  • Testing and reviewing localization for RTL languages and ensuring layout adapts correctly
Who it's for
  • iOS/macOS developers building multi-language apps
  • Localization engineers reviewing or improving existing localization workflows
  • App developers preparing for international App Store distribution
  • Swift package maintainers adding localization support to libraries

ios-localization FAQ

What's the difference between LocalizedStringKey, String(localized:), and LocalizedStringResource?

LocalizedStringKey is implicit in SwiftUI view initializers (Text, Button, Label). String(localized:) returns a resolved String for use outside SwiftUI. LocalizedStringResource carries localization info without resolving, used for App Intents, widgets, and notifications. Use LocalizedStringKey/String(localized:) for immediate display; use LocalizedStringResource when passing to APIs that accept it.

How do I enable generated symbols for compile-time-safe localization keys?

Build Settings > Localization > Generate String Catalog Symbols → Yes (on by default in Xcode 26). Catalog format must be version 1.1. Create manual keys or convert auto-extracted strings via Refactor > Convert Strings to Symbols. Xcode derives symbol names by camelCasing the key (e.g., 'room_available' → .roomAvailable).

How do String Catalogs handle pluralization?

String Catalogs natively support plural rules. Add a key, enable pluralization in the editor, and define singular/plural/zero forms. In code, use String(localized:) or generated symbols with a count parameter. Xcode applies the correct plural form based on locale rules automatically.

What's the best way to format dates, numbers, and currencies for different locales?

Use FormatStyle with the appropriate formatter: Date.FormatStyle, Decimal.FormatStyle, or Currency.FormatStyle. These automatically adapt to the user's locale, calendar, and currency preferences. Example: Text(date, style: .date) or Text(price, format: .currency(code: "USD")).

How do I ensure my app layout works correctly in right-to-left languages like Arabic?

Use semantic layout (leading/trailing instead of left/right), test in RTL locales via Xcode scheme settings, and verify Dynamic Type scaling. String Catalogs and FormatStyle handle text direction automatically; focus on layout constraints and image mirroring for RTL contexts.

Full instructions (SKILL.md)

Source of truth, from dpearson2699/swift-ios-skills.


name: ios-localization description: "Implement, review, or improve localization and internationalization in iOS/macOS apps — String Catalogs (.xcstrings), generated localizable symbols, stable key naming, LocalizedStringKey, LocalizedStringResource, pluralization, FormatStyle for numbers/dates/measurements, right-to-left layout, Dynamic Type, and locale-aware formatting. Use when adding multi-language support, setting up String Catalogs, enabling generated symbols for compile-time-safe localization keys, handling plural forms, formatting dates/numbers/currencies for different locales, testing localizations, or making UI work correctly in RTL languages like Arabic and Hebrew."

iOS Localization & Internationalization

Localize iOS 26+ apps using String Catalogs, modern string types, FormatStyle, and RTL-aware layout. Localization mistakes cause App Store rejections in non-English markets, mistranslated UI, and broken layouts. Ship with correct localization from the start.

Contents

String Catalogs (.xcstrings)

String Catalogs are the recommended Xcode 15+ workflow for new localization work. They keep localizable strings, pluralization rules, and device variations together in an Xcode-managed JSON file with a visual editor. Legacy .strings and .stringsdict files can coexist during migration, but new Swift and SwiftUI code should default to String Catalogs.

Why String Catalogs exist:

  • .strings files required manual key management and fell out of sync
  • .stringsdict required complex XML for plurals
  • String Catalogs auto-extract strings from code, track translation state, and support plurals natively

How automatic extraction works:

Xcode scans for these patterns on each build:

// SwiftUI -- automatically extracted (LocalizedStringKey)
Text("Welcome back")              // key: "Welcome back"
Label("Settings", systemImage: "gear")
Button("Save") { }
Toggle("Dark Mode", isOn: $dark)

// Programmatic -- automatically extracted
String(localized: "No items found")
LocalizedStringResource("Order placed")

// NOT extracted -- plain String, not localized
let msg = "Hello"                 // just a String, invisible to Xcode

Xcode adds discovered keys to the String Catalog automatically. Mark translations as Needs Review, Translated, or Stale in the editor.

For detailed String Catalog workflows, migration, and testing strategies, see references/string-catalogs.md.

String Catalogs (Xcode 15+) and Generated Symbols (Xcode 26+)

For generated-symbol or migration answers, start by stating: "String Catalogs are the recommended Xcode 15+ localization workflow. Xcode 26 generated symbols are a separate typed-access layer on top of String Catalogs." Then explain generated symbols, plurals, or migration details. Do not describe catalogs themselves as requiring Xcode 26 or iOS 17.

Enable: Build Settings > Localization > Generate String Catalog Symbols → Yes (on by default in new Xcode 26 projects). Requires catalog format version 1.1.

Workflow: Add a key manually via the (+) button in the String Catalog editor — manual keys have the Generate Swift Symbol checkbox enabled by default. Auto-extracted keys can also opt in via Refactor > Convert Strings to Symbols. Use stable manual keys for generated-symbol strings. Avoid source-copy-derived keys for API-facing strings because wording edits can rename generated identifiers and churn call sites.

// Generated from key "room_available" in Localizable.xcstrings
Text(.roomAvailable)

// Parameterized key "landmarks_count" with %1$(count)lld
Text(.landmarksCount(count: 42))

// Non-default table "Booking.xcstrings"
Text(.Booking.confirmBookingCta)

Xcode derives symbol names by camelCasing the key: settings.notifications.toggle.settingsNotificationsToggle. You can convert existing extracted strings to symbols via Refactor > Convert Strings to Symbols (reversible).

Generated symbols are internal. For cross-module access, create a public wrapper extension. For heavier multi-module setups, use xcstrings-tool instead.

For the full generated symbols reference — extraction states, symbol derivation rules, and cross-module patterns — see references/string-catalogs.md.

String Types -- Decision Guide

LocalizedStringKey (SwiftUI default)

SwiftUI views accept LocalizedStringKey for their text parameters. String literals are implicitly converted -- no extra work needed.

// These all create a LocalizedStringKey lookup automatically:
Text("Welcome back")
Label("Profile", systemImage: "person")
Button("Delete") { deleteItem() }
.navigationTitle("Home")

Use LocalizedStringKey when passing strings directly to SwiftUI view initializers. Do not construct LocalizedStringKey manually in most cases.

String(localized:) -- Modern NSLocalizedString replacement

Use for any localized string outside a SwiftUI view initializer. Returns a plain String. The literal/interpolated initializer is available iOS 15+; resolving a LocalizedStringResource is iOS 16+.

// Basic
let title = String(localized: "Welcome back")

// With default value (key differs from English text)
let msg = String(localized: "error.network",
                 defaultValue: "Check your internet connection")

// With table and bundle
let label = String(localized: "onboarding.title",
                   table: "Onboarding",
                   bundle: .module)

// With comment for translators
let btn = String(localized: "Save",
                 comment: "Button title to save the current document")

For Swift package localization failures, answer with this explicit resource checklist before bundle debugging:

  1. Package.swift declares defaultLocalization.
  2. The target resources list processes the catalog location, such as .process("Resources").
  3. Localizable.xcstrings is actually inside that processed target-resource path. Only after those pass, debug lookup with bundle: .module or Text(..., bundle: .module).

Existing NSLocalizedString literal keys can still be exported or migrated by Xcode tooling, but new Swift code should prefer String(localized:), SwiftUI literals, LocalizedStringResource, or generated symbols.

LocalizedStringResource -- Pass localization info without resolving

Use when a string must be carried as a localizable value for later resolution, especially for App Intents, widgets, notifications, generated localizable symbols, and system APIs that accept LocalizedStringResource directly. Use String(localized:) when code needs the resolved string immediately. Available iOS 16+.

// App Intents require LocalizedStringResource
struct OrderCoffeeIntent: AppIntent {
    static var title: LocalizedStringResource = "Order Coffee"
}

// Widgets
struct MyWidget: Widget {
    var body: some WidgetConfiguration {
        StaticConfiguration(kind: "timer",
                            provider: Provider()) { entry in
            TimerView(entry: entry)
        }
        .configurationDisplayName(LocalizedStringResource("Timer"))
    }
}

// Pass around without resolving yet
func showAlert(title: LocalizedStringResource, message: LocalizedStringResource) {
    // Resolved at display time with the user's current locale
    let resolved = String(localized: title)
}

When to use each type

ContextTypeWhy
SwiftUI view text parametersLocalizedStringKey (implicit)SwiftUI handles lookup automatically
Computed strings in view models / servicesString(localized:)Returns resolved String for logic
App Intents, widgets, system APIsLocalizedStringResourceFramework resolves at display time
Error messages shown to usersString(localized:)Resolved in catch blocks
Logging / analytics (not user-facing)Plain StringNo localization needed

String Interpolation in Localized Strings

Interpolated values in localized strings become positional arguments that translators can reorder.

// English: "Welcome, Alice! You have 3 new messages."
// German:  "Willkommen, Alice! Sie haben 3 neue Nachrichten."
// Japanese: "Alice さん、新しいメッセージが 3 件あります。"
let text = String(localized: "Welcome, \(name)! You have \(count) new messages.")

In the String Catalog, this appears with %@ and %lld placeholders that translators can reorder:

  • English: "Welcome, %@! You have %lld new messages."
  • Japanese: "%@さん、新しいメッセージが%lld件あります。"

Type-safe interpolation (preferred over format specifiers):

// Interpolation provides type safety
String(localized: "Score: \(score, format: .number)")
String(localized: "Due: \(date, format: .dateTime.month().day())")

Pluralization

String Catalogs handle pluralization natively -- no .stringsdict XML required.

Setup in String Catalog

When a localized string contains an integer interpolation, Xcode detects it and offers plural variants in the String Catalog editor. Supply translations for each CLDR plural category:

CategoryEnglish exampleArabic example
zero(not used)0 items
one1 item1 item
two(not used)2 items (dual)
few(not used)3-10 items
many(not used)11-99 items
other2+ items100+ items

English uses only one and other. Arabic uses all six. Always supply other as the fallback.

// Code -- single interpolation triggers plural support
Text("\(unreadCount) unread messages")

// String Catalog entries (English):
//   one:   "%lld unread message"
//   other: "%lld unread messages"

Device Variations

String Catalogs support device-specific text (iPhone vs iPad vs Mac):

// In String Catalog editor, enable "Vary by Device" for a key
// iPhone: "Tap to continue"
// iPad:   "Tap or click to continue"
// Mac:    "Click to continue"

Grammar Agreement (iOS 15+)

Use ^[...] inflection syntax for automatic grammatical agreement:

// Automatically adjusts for gender/number in supported languages
Text("^[\(count) \("photo")](inflect: true) added")
// English: "1 photo added" / "3 photos added"
// Spanish: "1 foto agregada" / "3 fotos agregadas"

FormatStyle -- Locale-Aware Formatting

Never hard-code date, number, or measurement formats. Use FormatStyle (iOS 15+) so formatting adapts to the user's locale automatically.

Locale-aware formatting matters even in single-language apps because user locale affects separators, calendars, currency, units, names, and list formatting. When giving user-facing formatting advice, explicitly recommend testing or previewing output under multiple locales such as en_US, de_DE, ar_SA, and ja_JP.

ios-localization owns FormatStyle guidance when the issue is locale-aware user-facing display, including numbers, dates, currency, units, names, lists, calendars, separators, and locale preview/testing. For custom FormatStyle, ParseableFormatStyle, parsing, Date.IntervalFormatStyle, URL.FormatStyle, or reusable formatter API design, route to swift-formatstyle; keep ios-localization advice to locale risks and testing unless implementation is explicitly requested.

Dates

let now = Date.now

// Preset styles
now.formatted(date: .long, time: .shortened)
// US: "January 15, 2026 at 3:30 PM"
// DE: "15. Januar 2026 um 15:30"
// JP: "2026年1月15日 15:30"

// Component-based
now.formatted(.dateTime.month(.wide).day().year())
// US: "January 15, 2026"

// In SwiftUI
Text(now, format: .dateTime.month().day().year())

Numbers

let count = 1234567
count.formatted()                     // "1,234,567" (US) / "1.234.567" (DE)
count.formatted(.number.precision(.fractionLength(2)))
count.formatted(.percent)             // For 0.85 -> "85%" (US) / "85 %" (FR)

// Currency
let price = Decimal(29.99)
price.formatted(.currency(code: "USD"))  // "$29.99" (US) / "29,99 $US" (FR)
price.formatted(.currency(code: "EUR"))  // "29,99 EUR" (DE)

Measurements

let distance = Measurement(value: 5, unit: UnitLength.kilometers)
distance.formatted(.measurement(width: .wide))
// US: "3.1 miles" (auto-converts!) / DE: "5 Kilometer"

let temp = Measurement(value: 22, unit: UnitTemperature.celsius)
temp.formatted(.measurement(width: .abbreviated))
// US: "72 F" (auto-converts!) / FR: "22 C"

Duration, PersonName, Lists

// Duration
let dur = Duration.seconds(3661)
dur.formatted(.time(pattern: .hourMinuteSecond))  // "1:01:01"

// Person names
let name = PersonNameComponents(givenName: "John", familyName: "Doe")
name.formatted(.name(style: .long))   // "John Doe" (US) / "Doe John" (JP)

// Lists
let items = ["Apples", "Oranges", "Bananas"]
items.formatted(.list(type: .and))    // "Apples, Oranges, and Bananas" (EN)
                                      // "Apples, Oranges et Bananas" (FR)

For the complete FormatStyle reference, custom styles, and RTL layout, see references/formatstyle-locale.md.

Right-to-Left (RTL) Layout

SwiftUI automatically mirrors layouts for RTL languages (Arabic, Hebrew, Urdu, Persian). Most views require zero changes.

What SwiftUI auto-mirrors

  • HStack children reverse order
  • .leading / .trailing alignment and padding swap sides
  • NavigationStack back button moves to trailing edge
  • List disclosure indicators flip
  • Text alignment follows reading direction

What needs manual attention

// Testing RTL in previews
MyView()
    .environment(\.layoutDirection, .rightToLeft)
    .environment(\.locale, Locale(identifier: "ar"))

// Images that should mirror (directional arrows, progress indicators)
Image(systemName: "chevron.right")
    .flipsForRightToLeftLayoutDirection(true)

// Images that should NOT mirror: logos, photos, clocks, music notes

// Forced LTR for specific content (phone numbers, code)
Text("+1 (555) 123-4567")
    .environment(\.layoutDirection, .leftToRight)

Layout rules

  • DO use .leading / .trailing -- they auto-flip for RTL
  • DON'T use .left / .right -- they are fixed and break RTL
  • DO use HStack / VStack -- they respect layout direction
  • DON'T use absolute offset(x:) for directional positioning

Common Mistakes

DON'T: Use NSLocalizedString in new Swift code

// LEGACY -- Xcode can export literal keys, but new Swift code should use modern APIs
let title = NSLocalizedString("welcome_title", comment: "Welcome screen title")

DO: Use String(localized:) or let SwiftUI handle it

// CORRECT
let title = String(localized: "welcome_title",
                   defaultValue: "Welcome!",
                   comment: "Welcome screen title")
// Or in SwiftUI, just:
Text("Welcome!")

DON'T: Concatenate localized strings

// WRONG -- word order varies by language
let greeting = String(localized: "Hello") + ", " + name + "!"

DO: Use string interpolation

// CORRECT -- translators can reorder placeholders
let greeting = String(localized: "Hello, \(name)!")

DON'T: Hard-code date/number formats

// WRONG -- US-only format
let formatter = DateFormatter()
formatter.dateFormat = "MM/dd/yyyy"  // Meaningless in most countries

DO: Use FormatStyle

// CORRECT -- adapts to user locale
Text(date, format: .dateTime.month().day().year())

DON'T: Use fixed-width layouts

// WRONG -- German text is ~30% longer than English
Text(title).frame(width: 120)

DO: Use flexible layouts

// CORRECT
Text(title).fixedSize(horizontal: false, vertical: true)
// Or use VStack/wrapping that accommodates expansion

DON'T: Use .left / .right for alignment

// WRONG -- does not flip for RTL
HStack { Spacer(); text }.padding(.left, 16)

DO: Use .leading / .trailing

// CORRECT
HStack { Spacer(); text }.padding(.leading, 16)

DON'T: Put user-facing strings as plain String outside SwiftUI

// WRONG -- not localized
let errorMessage = "Something went wrong"
showAlert(message: errorMessage)

DO: Use LocalizedStringResource for deferred resolution

// CORRECT
let errorMessage = LocalizedStringResource("Something went wrong")
showAlert(message: String(localized: errorMessage))

DON'T: Use natural-language text as the key for manually-managed strings

// WRONG -- typo silently creates a new key, stales the old one, no compiler error
Text("Wlecome Back")  // was "Welcome Back" -- silent localization break

DO: Use stable symbol-style keys and enable generated symbols

// CORRECT -- key is stable; UI text lives in the catalog's default value
Text(.welcomeBack)  // generated from key "welcome_back" in String Catalog
// Or without generated symbols:
String(localized: "welcome_back", defaultValue: "Welcome Back")

DON'T: Skip pseudolocalization testing

Testing only in English hides truncation, layout, and RTL bugs.

DO: Test with German (long) and Arabic (RTL) at minimum

Use Xcode scheme settings to override the app language without changing device locale.

Review Checklist

  • All user-facing strings use localization (LocalizedStringKey in SwiftUI or String(localized:))
  • No string concatenation for user-visible text
  • Dates and numbers use FormatStyle, not hardcoded formats
  • Pluralization handled via String Catalog plural variants (not manual if/else)
  • Layout uses .leading / .trailing, not .left / .right
  • UI tested with long text (German) and RTL (Arabic)
  • String Catalog includes all target languages
  • Images needing RTL mirroring use .flipsForRightToLeftLayoutDirection(true)
  • App Intents and widgets use LocalizedStringResource
  • No NSLocalizedString usage in new code
  • Comments provided for ambiguous keys (context for translators)
  • @ScaledMetric used for spacing that must scale with Dynamic Type
  • Currency formatting uses explicit currency code, not locale default
  • Pseudolocalization tested (accented, right-to-left, double-length)
  • Manually-managed keys use stable symbol-style names, not English text as the key
  • Generate String Catalog Symbols enabled for targets with manually-managed keys
  • Ensure localized string types are Sendable; use @MainActor for locale-change UI updates

References

Related skills

More from dpearson2699/swift-ios-skills and the wider catalog.

ios-networking logo

ios-networking

dpearson2699/swift-ios-skills

Modern iOS/macOS networking with URLSession, async/await, and structured concurrency.

2.5k installs
ios-security logo

ios-security

dpearson2699/swift-ios-skills

Secure iOS apps with Keychain Services, CryptoKit encryption, biometric authentication (Face ID, Touch ID), Secure Enclave key storage, LAContext, App Transport Security (ATS), certificate pinning, data protection classes, and secure coding patterns. Use when implementing app security features, auditing privacy manifests, configuring App Transport Security, securing keychain access, adding biometric authentication, or encrypting sensitive data with CryptoKit.

1.1k installs
ios-simulator logo

ios-simulator

dpearson2699/swift-ios-skills

Manages iOS Simulator devices and tests app behavior using xcrun simctl. Covers device lifecycle (create, boot, shutdown, erase, delete), app install and launch, push notification simulation, location simulation, permission grants via privacy subcommand, deep link testing via openurl, status bar overrides, screenshot and video recording, log streaming with os_log filtering, get_app_container paths, and #if targetEnvironment(simulator) compile-time checks. Use when creating or managing simulator devices, testing push notifications without APNs, simulating GPS locations, granting or resetting privacy permissions, capturing screenshots or screen recordings from the command line, streaming device logs, debugging simulator boot failures, troubleshooting CoreSimulator issues, or checking simulator hardware limitations.

1.2k installsAudited
mapkit logo

mapkit

dpearson2699/swift-ios-skills

Build map and location features in iOS/macOS apps with MapKit and CoreLocation async APIs.

1.7k installsAudited
metrickit logo

metrickit

dpearson2699/swift-ios-skills

Collect production performance metrics and crash diagnostics from iOS/macOS devices using MetricKit.

1.7k installsAudited
musickit logo

musickit

dpearson2699/swift-ios-skills

Integrate Apple Music playback, catalog search, and Now Playing metadata into iOS apps.

1.6k installsAudited