ARC Labs Studio - Localization
Quick Decision Tree
What are you localizing?
├── Navigation title → String(localized:locale:) + @Environment(\.locale)
├── Tab label → LocalizedStringKey via ARCTabItem protocol
├── Domain entity name in a View → LocalizedStringKey(entity.nameKey)
├── Domain entity name for logging → entity.name (String(localized:))
├── Package enum title → var title: LocalizedStringKey
├── Package view title → LocalizedStringKey parameter
└── Menu item subtitle → String(localized:locale:) via ViewModel helper
Core Principle
Packages are text-agnostic. Apps own all strings.
Packages use LocalizedStringKey. Apps provide translations via .xcstrings.
The Two-System Problem
| API | Resolves Against | Immediate? |
|---|---|---|
LocalizedStringKey |
@Environment(\.locale) |
Yes |
String(localized:) |
Locale.current (process) |
No (cold restart) |
String(localized:locale:) |
Explicit Locale | Yes (with @Environment) |
Key Patterns
Navigation Titles
@Environment(\.locale) private var locale
// ...
.navigationTitle(String(localized: "Favorites", locale: locale))
Domain Entity nameKey
// Domain layer (no SwiftUI)
var nameKey: String { "Italian" }
// Presentation layer
Text(LocalizedStringKey(cuisineType.nameKey))
Package Enums
public var title: LocalizedStringKey {
switch self {
case .system: "System" // App's xcstrings provides translation
}
}
Full Reference
See Quality/localization.md for complete standards, LanguageManager pattern, and decision matrix.