Aller au contenu
iOS i18n

Localisation iOS : Workflows de traduction natifs avec Swift et SwiftUI

iOS utilise les String Catalogs (Xcode 15+) et les fichiers .strings/.stringsdict pour gérer les traductions. Les vues SwiftUI sont automatiquement localisées via l'initialiseur Text(), et Xcode gère l'extraction, les règles de pluralisation et l'export en XLIFF pour les traducteurs. Avec les String Catalogs, vous bénéficiez d'un éditeur visuel qui suit l'état des traductions pour chaque langue prise en charge.

Fonctionnalités de localisation iOS

String Catalogs (.xcstrings) avec éditeur de traduction visuel et suivi des états
Localisation automatique SwiftUI via Text() et LocalizedStringKey
Pluralisation et accord grammatical via .stringsdict et le moteur grammatical automatique
Export/import XCLOC pour la remise à des traducteurs professionnels via Xcode
Localisation des Storyboard et XIB avec intégration Interface Builder
Contraintes Auto Layout qui s'adaptent aux changements de longueur de texte et de direction de mise en page
Prise en charge du droite-à-gauche (RTL) avec la sémantique de mise en page leading/trailing
Formateurs Foundation pour les dates, chiffres et mesures adaptés aux paramètres régionaux
Localisation du bundle d'application avec des répertoires .lproj pour les ressources par locale

La localisation iOS en pratique

Les vues SwiftUI sont automatiquement localisées lorsque vous utilisez des littéraux de chaîne dans Text(). Les String Catalogs gèrent la pluralisation et les variations d'appareils dans un seul fichier.

// SwiftUI - Automatic localization
struct WelcomeView: View {
    let name: String

    var body: some View {
        VStack {
            // Automatically looks up "Welcome to %@" in String Catalog
            Text("Welcome to \(name)")

            // Pluralization via String Catalog
            Text("^[\(itemCount) item](inflect: true)")

            // Date formatting respects locale
            Text(Date.now, format: .dateTime.month(.wide).day())
        }
    }
}

// Localizable.xcstrings (String Catalog)
// Managed in Xcode - supports:
// - Automatic extraction from SwiftUI
// - Pluralization rules per locale
// - String variation by device
// - Translation state tracking

iOS Localization — Frequently Asked Questions

What is the recommended approach for iOS localization in 2026?

Apple's recommended approach is String Catalogs (.xcstrings), introduced in Xcode 15. String Catalogs replace the older .strings and .stringsdict files with a single JSON-based file that supports all plural rules, device-specific variants, and string variations. Xcode automatically extracts localizable strings from your Swift and SwiftUI code, and tracks translation completion percentage per locale.

How does Better i18n work with Xcode and String Catalogs?

Better i18n uses its CLI to export translations from your String Catalogs, push them to the dashboard for professional translation or AI-assisted translation, then import the translated files back into Xcode. The workflow is: `better-i18n push` exports your .xcstrings file, translators work in the Better i18n dashboard, and `better-i18n pull` downloads the completed translations back into Xcode format. This replaces manual .xcloc file management.

What is the difference between NSLocalizedString and SwiftUI's native localization?

NSLocalizedString is the UIKit/AppKit API that looks up a key in your .strings bundle. SwiftUI's Text() view performs automatic localization — it uses the string literal as the key itself, which means your source code is self-documenting. Both approaches work with String Catalogs in Xcode 15+. For new SwiftUI projects, the automatic approach is cleaner; for UIKit projects maintaining existing .strings files, NSLocalizedString remains the standard.

How do I implement RTL (right-to-left) support on iOS?

iOS handles RTL layout automatically when the user selects an RTL language like Arabic or Hebrew. SwiftUI's layout system uses leading/trailing instead of left/right, and UIKit respects UIView.semanticContentAttribute. The key is to avoid hardcoded left/right margins and use Auto Layout with leading/trailing constraints. Better i18n supports Arabic and Hebrew as target languages and handles bidirectional text in the translation editor.

Can I use over-the-air (OTA) translation updates on iOS?

Apple's App Store review policy requires that core app functionality not change between reviews, but translation content updates are generally permitted via OTA mechanisms. Better i18n's native Swift SDK (BetterI18n) fetches translations from the CDN at runtime, allowing you to push translation corrections and new language support without an app store release. The SDK uses a two-phase load: it reads from local storage first for instant display, then refreshes from CDN in the background.

What pluralization rules does iOS support and how many are there?

iOS supports all Unicode CLDR plural categories: zero, one, two, few, many, and other. Not all languages use all categories — English only uses one and other, while Arabic uses all six. String Catalogs in Xcode 15 automatically show the relevant plural forms for each target locale. Better i18n's translation editor also surfaces the correct plural forms per language so translators never miss a required plural case.

Commencez la localisation iOS dès aujourd'hui

Gérez les traductions de votre String Catalog iOS avec des workflows assistés par IA, la synchronisation CLI et une distribution CDN en moins de 50 ms.