How to Translate an iOS App with Swift: Complete Guide

Learn how to localize your iOS app using Swift and Xcode. This comprehensive guide covers string localization, pluralization, date formatting, and best practices for iOS app translation.

  • date icon

    Wednesday, Nov 12, 2025

How to Translate an iOS App with Swift: Complete Guide

Translating your iOS app is essential for reaching a global audience. Apple provides excellent built-in tools for localization in Xcode, making it straightforward to support multiple languages. This guide will walk you through the process of translating an iOS app using Swift.

Understanding iOS Localization

iOS localization uses Localizable.strings files to store translations for different languages. Xcode automatically loads the correct strings based on the user’s device language settings.

Step 1: Enable Localization in Your Project

First, you need to enable localization for your project:

  1. Open your project in Xcode
  2. Select your project in the Project Navigator
  3. Go to the Info tab
  4. Under Localizations, click the + button
  5. Add the languages you want to support (e.g., Spanish, French, German)

Step 2: Create Localizable.strings Files

For each language, you’ll create a Localizable.strings file:

  1. In Xcode, go to File > New > File
  2. Select Strings File under Resource
  3. Name it Localizable.strings
  4. In the File Inspector, click Localize…
  5. Select the languages you want to support

Step 3: Add Translation Strings

In your Localizable.strings files, add key-value pairs for each language:

English (Localizable.strings):

"welcome_message" = "Welcome to our app!";
"button_submit" = "Submit";
"error_network" = "Network error. Please try again.";
"items_count" = "%d items";

Spanish (Localizable.strings (es)):

"welcome_message" = "¡Bienvenido a nuestra aplicación!";
"button_submit" = "Enviar";
"error_network" = "Error de red. Por favor, inténtalo de nuevo.";
"items_count" = "%d elementos";

Step 4: Use NSLocalizedString in Your Code

Replace hardcoded strings with NSLocalizedString:

Before:

let welcomeLabel = UILabel()
welcomeLabel.text = "Welcome to our app!"

After:

let welcomeLabel = UILabel()
welcomeLabel.text = NSLocalizedString("welcome_message", comment: "Welcome message displayed on home screen")

Step 5: Handle String Formatting

For strings with variables, use String.localizedStringWithFormat:

let itemCount = 5
let message = String.localizedStringWithFormat(
    NSLocalizedString("items_count", comment: "Number of items"),
    itemCount
)
// English: "5 items"
// Spanish: "5 elementos"

Step 6: Pluralization

iOS supports pluralization using .stringsdict files. Create a Localizable.stringsdict file:

Localizable.stringsdict:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>items_count</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>%#@items@</string>
        <key>items</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>d</string>
            <key>zero</key>
            <string>No items</string>
            <key>one</key>
            <string>%d item</string>
            <key>other</key>
            <string>%d items</string>
        </dict>
    </dict>
</dict>
</plist>

Usage:

let count = 1
let message = String.localizedStringWithFormat(
    NSLocalizedString("items_count", comment: ""),
    count
)
// English: "1 item" (singular)
// English: "5 items" (plural)

Step 7: Localize Images and Assets

You can also localize images:

  1. Select an image in your Assets.xcassets
  2. In the Attributes Inspector, check Localize
  3. Provide different images for each language

Or use localized image names:

let imageName = NSLocalizedString("icon_name", comment: "")
let image = UIImage(named: imageName)

Step 8: Format Dates and Numbers

Use Locale and DateFormatter for localized formatting:

let date = Date()
let formatter = DateFormatter()
formatter.locale = Locale.current
formatter.dateStyle = .long
formatter.timeStyle = .short

let localizedDate = formatter.string(from: date)
// English: "March 20, 2025 at 10:00 AM"
// Spanish: "20 de marzo de 2025, 10:00"

For numbers:

let number = 1234.56
let formatter = NumberFormatter()
formatter.locale = Locale.current
formatter.numberStyle = .decimal

let localizedNumber = formatter.string(from: NSNumber(value: number))
// English: "1,234.56"
// Spanish: "1.234,56"

Step 9: Test Your Localization

Test your app in different languages:

  1. In Xcode, go to Product > Scheme > Edit Scheme
  2. Select Run and go to Options
  3. Change Application Language to test different languages
  4. Run your app to see the translations

Or test on a device:

  1. Go to Settings > General > Language & Region
  2. Change the device language
  3. Launch your app

Best Practices

1. Use Descriptive Keys

Bad:

NSLocalizedString("msg1", comment: "")

Good:

NSLocalizedString("welcome_screen_title", comment: "Title displayed on the welcome screen")

2. Provide Context in Comments

Always include comments to help translators understand the context:

NSLocalizedString("delete_button", comment: "Button to delete an item. Shown in the item detail view.")

3. Avoid Concatenating Strings

Bad:

let message = NSLocalizedString("hello", comment: "") + " " + name

Good:

let message = String.localizedStringWithFormat(
    NSLocalizedString("hello_user", comment: "Greeting with user name"),
    name
)

4. Handle Right-to-Left Languages

iOS automatically handles RTL languages like Arabic and Hebrew. Ensure your UI constraints support both directions:

// Use leading/trailing instead of left/right
button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20)

5. Test String Lengths

Some languages are longer than others. German and Finnish, for example, can be 30-50% longer than English. Design your UI to accommodate longer text.

Common Pitfalls

1. Forgetting to Localize All Strings

Make sure to localize all user-facing strings, including:

  • Button labels
  • Error messages
  • Alert titles
  • Placeholder text

2. Hardcoding Format Strings

Bad:

let price = String(format: "$%.2f", amount)

Good:

let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = Locale.current
let price = formatter.string(from: NSNumber(value: amount)) ?? ""

3. Not Testing Edge Cases

Test with:

  • Very long strings
  • Special characters
  • Numbers and dates
  • Plural forms

Advanced: Dynamic Language Switching

To allow users to change language within the app:

func changeLanguage(to language: String) {
    UserDefaults.standard.set([language], forKey: "AppleLanguages")
    UserDefaults.standard.synchronize()
    
    // Restart app or reload UI
    Bundle.setLanguage(language)
}

Note: This requires additional setup and may require app restart.

Conclusion

Localizing your iOS app with Swift is straightforward when you follow these steps:

  1. Enable localization in Xcode
  2. Create Localizable.strings files for each language
  3. Use NSLocalizedString throughout your code
  4. Handle pluralization with .stringsdict files
  5. Format dates and numbers using Locale
  6. Test thoroughly in all supported languages

By following these practices, you’ll create an app that provides a native experience for users worldwide, significantly expanding your potential user base.

Streamline Your iOS Localization Workflow

Managing translations for multiple languages can become complex as your app grows. Consider using a translation management platform to:

  • Collaborate with translators
  • Keep translations in sync with your codebase
  • Automate the translation workflow
  • Maintain consistency across all languages

Ready to take your iOS app global? Explore AZbox’s localization platform and streamline your translation workflow:

View AZbox Plans and Pricing

Blog

Latest Posts

Discover our latest articles and updates.

Why Translations Have Always Been a Problem in Software Development
date icon

Sunday, Dec 21, 2025

Why Translations Have Always Been a Problem in Software Development

For decades, software developers have struggled with translations and localization. What should be a straightforward pro

Read More
Cómo Traducir una App Flutter con Azbox: Guía Completa
date icon

Saturday, Dec 20, 2025

Cómo Traducir una App Flutter con Azbox: Guía Completa

Traducir tu app Flutter es esencial para llegar a una audiencia global. Azbox proporciona un potente SDK de Flutter que

Read More
How to Translate a Flutter App with Azbox: Complete Guide
date icon

Saturday, Dec 20, 2025

How to Translate a Flutter App with Azbox: Complete Guide

Translating your Flutter app is essential for reaching a global audience. Azbox provides a powerful Flutter SDK that sim

Read More
cta-image

Start Global Growth Today

Join hundreds of successful companies already using AZbox to reach customers worldwide. Start with a free trial, no credit card required.

Get Started - It's Free