diff --git a/Package.swift b/Package.swift index 1fa3628..dc2732a 100644 --- a/Package.swift +++ b/Package.swift @@ -13,6 +13,7 @@ import PackageDescription let package = Package( name: "SpeziFoundation", + defaultLocalization: "en", platforms: [ .iOS(.v17), .watchOS(.v10), @@ -26,6 +27,9 @@ let package = Package( targets: [ .target( name: "SpeziFoundation", + resources: [ + .process("Resources") + ], swiftSettings: [ .enableExperimentalFeature("StrictConcurrency") ] diff --git a/Sources/SpeziFoundation/Misc/TimeoutError.swift b/Sources/SpeziFoundation/Misc/TimeoutError.swift index 3a5e708..0dedba6 100644 --- a/Sources/SpeziFoundation/Misc/TimeoutError.swift +++ b/Sources/SpeziFoundation/Misc/TimeoutError.swift @@ -16,7 +16,15 @@ public struct TimeoutError { } -extension TimeoutError: Error {} +extension TimeoutError: LocalizedError { + public var errorDescription: String? { + String(localized: LocalizedStringResource("Timeout", bundle: .atURL(Bundle.module.bundleURL))) + } + + public var failureReason: String? { + String(localized: LocalizedStringResource("The operation timed out.", bundle: .atURL(Bundle.module.bundleURL))) + } +} /// Race a timeout. diff --git a/Sources/SpeziFoundation/Resources/Localizable.xcstrings b/Sources/SpeziFoundation/Resources/Localizable.xcstrings new file mode 100644 index 0000000..6e95e2d --- /dev/null +++ b/Sources/SpeziFoundation/Resources/Localizable.xcstrings @@ -0,0 +1,38 @@ +{ + "sourceLanguage" : "en", + "strings" : { + "The operation timed out." : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Der Vorgang hat das Zeitlimit überschritten." + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "The operation timed out." + } + } + } + }, + "Timeout" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Zeitüberschreitung" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Timeout" + } + } + } + } + }, + "version" : "1.0" +} \ No newline at end of file diff --git a/Sources/SpeziFoundation/Resources/Localizable.xcstrings.license b/Sources/SpeziFoundation/Resources/Localizable.xcstrings.license new file mode 100644 index 0000000..a648e99 --- /dev/null +++ b/Sources/SpeziFoundation/Resources/Localizable.xcstrings.license @@ -0,0 +1,5 @@ +This source file is part of the Stanford Spezi open-source project + +SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) + +SPDX-License-Identifier: MIT