iOS Localization - LocEngine Features

iOS Localization

Complete guide to localizing iOS apps with LocEngine

Overview

iOS uses .strings files for localization, with support for plural forms through .stringsdict. LocEngine provides comprehensive support for Swift and Objective-C projects, including storyboard strings, code strings, and complex plural rules.

Working with .strings Files

/* Localizable.strings (English) */
"welcome_title" = "Welcome to Our App";
"greeting_message" = "Hello, %@!";
"button_ok" = "OK";
"button_cancel" = "Cancel";
"items_count" = "You have %d items";

Adding Languages

LocEngine automatically creates language-specific .lproj folders:

MyApp.xcodeproj/
├── en.lproj/
│ ├── Localizable.strings
│ └── Main.strings (storyboard strings)
├── fa.lproj/ (Persian)
│ ├── Localizable.strings
│ └── Main.strings
└── ar.lproj/ (Arabic)
├── Localizable.strings
└── Main.strings

Plural Support with .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>number_of_messages</key>
  <dict>
    <key>NSStringLocalizedFormatKey</key>
    <string>%#@messages@</string>
    <key>messages</key>
    <dict>
      <key>NSStringFormatSpecTypeKey</key>
      <string>NSStringPluralRuleType</string>
      <key>NSStringFormatValueTypeKey</key>
      <string>d</string>
      <key>one</key>
      <string>%d message</string>
      <key>other</key>
      <string>%d messages</string>
    </dict>
  </dict>
</dict>
</plist>
💡 Pro Tip: LocEngine automatically detects strings in SwiftUI and UIKit code, including string interpolation and formatting.

Swift Code Example

// Before (hardcoded)
let label = UILabel()
label.text = "Welcome to our app"

// After (localized)
let label = UILabel()
label.text = NSLocalizedString("welcome_title", comment: "")

// With formatting
let count = 5
let message = String(format: NSLocalizedString("items_count", comment: ""), count)

Storyboard Localization

LocEngine can extract strings from storyboards and XIB files, creating the corresponding .strings files automatically.