SwiftUI-capable SPM library for deferred, catalog-backed localization. It owns
the framework-level tooling; each app module keeps its own LocalizedStrings
enum and Localizable.xcstrings catalog.
LocalizedString— a user-facing string that hasn't been localized yet. It wraps a@Sendablebuilder closure and resolves lazily when you call.localized(_:). Per-moduleLocalizedStringsenums return these instead ofString, deferring the catalog lookup to the point of display so a call site can override the locale. It'sSendable, so producers can cache each string in astatic letand pass it across isolation boundaries.LocalizationConfig— a small value type (today just aLocale) passed to.localized(config)to render against a locale other than the process default.LocalizedString.catalog(_:_:bundle:)— the generic factory that performs aString(localized:bundle:locale:)lookup. Each module wraps it in a thin.module(_:_:)that passesbundle: .module.Text(localized:)andViewoverloads ofnavigationTitle,accessibilityLabel, andaccessibilityHint— resolve aLocalizedStringat the point of display.
import LocalizationKit
// In each module's LocalizedString+Module.swift:
extension LocalizedString {
static func module(_ key: StaticString, _ value: String.LocalizationValue) -> LocalizedString {
.catalog(key, value, bundle: .module)
}
}
// In LocalizedStrings.swift:
static let greeting: LocalizedString = .module("greeting", "Hello")
// At a SwiftUI call site (with dot-syntax accessors on LocalizedString):
Text(localized: .primary.emptyDescription)
.navigationTitle(.settings.title)
// Where a plain String is needed:
Button(LocalizedStrings.Common.done.localized) { … }Add shared types under Sources/ and wire consumers in
Package.swift. Run tests with
tuist test LocalizationKitTests.