Skip to content

Commit 674cd84

Browse files
committed
Move provider docs into code comments
1 parent 5db3bb3 commit 674cd84

4 files changed

Lines changed: 7 additions & 26 deletions

File tree

README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,6 @@ If you want to see how this package is used in practice, check the demo app in:
204204

205205
The demo app uses `TranslationPreparationGate` at the root and shows both SwiftUI and UIKit preview screens under the same preparation flow.
206206

207-
## Built-in Providers
208-
209-
### `AppleTranslationProvider`
210-
211-
Use it when you want a simpler way to integrate Apple Translate and translate strings without repeatedly wiring Apple Translation APIs yourself.
212-
213-
Pair it with `TranslationPreparationGate` for the quickest setup, or use `TranslationPreparationCoordinator` when you need a custom preparation UI.
214-
215-
### `PseudoLocalizationProvider`
216-
217-
Use this when you want to stress test UI layout.
218-
219-
It:
220-
221-
- replaces some characters with accented versions
222-
- pads text length to mimic longer translations
223-
- adds a visible language marker around the output
224-
225-
### `MockLocalizationProvider`
226-
227-
Useful when you want deterministic debug output without depending on external translation behavior.
228-
229-
### `PassthroughLocalizationProvider`
230-
231-
Returns the original text unchanged.
232-
233207
## License
234208

235209
MIT

Sources/DebugLocalizationCore/DebugLocalizationProvider.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import Foundation
22

3+
/// A pluggable translation backend used by `DebugLocalizer` and `DebugTranslate`.
34
public protocol LocalizationProvider: Sendable {
45
func translate(_ text: String) async -> String
56
}
67

8+
/// A translation provider that can return results immediately without async work.
79
public protocol SyncLocalizationProvider: LocalizationProvider {
810
func translateSynchronously(_ text: String) -> String
911
}

Sources/DebugLocalizationCore/PseudoLocalizationProvider.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22

3+
/// A sync provider that expands and accents text to stress test localized UI layout.
34
public struct PseudoLocalizationProvider: SyncLocalizationProvider {
45
public init() {}
56

@@ -37,6 +38,7 @@ public struct PseudoLocalizationProvider: SyncLocalizationProvider {
3738
}
3839
}
3940

41+
/// A sync provider that returns the original text unchanged.
4042
public struct PassthroughLocalizationProvider: SyncLocalizationProvider {
4143
public init() {}
4244

@@ -45,6 +47,7 @@ public struct PassthroughLocalizationProvider: SyncLocalizationProvider {
4547
}
4648
}
4749

50+
/// A sync provider that adds the current language code to the original text for deterministic previews.
4851
public struct MockLocalizationProvider: SyncLocalizationProvider {
4952
public init() {}
5053

Sources/DebugLocalizationTranslationSupport/AppleTranslationProvider.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DebugLocalizationCore
44
import Translation
55
#endif
66

7+
/// A translation provider that wraps Apple Translation behind the shared localization API.
78
public struct AppleTranslationProvider: LocalizationProvider, @unchecked Sendable {
89
typealias AppLanguageIdentifierProvider = () -> String
910
typealias EnglishLanguageIdentifierChecker = (String) -> Bool
@@ -78,6 +79,7 @@ public struct AppleTranslationProvider: LocalizationProvider, @unchecked Sendabl
7879

7980
#if canImport(Translation)
8081
@available(iOS 18.0, *)
82+
/// The source and target language pair resolved for Apple Translation.
8183
public struct Preparation: Sendable {
8284
public let sourceLanguage: Locale.Language
8385
public let targetLanguage: Locale.Language

0 commit comments

Comments
 (0)