-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Uni-boy/feature/create-decodable-models
Model Setup for String Catalog
- Loading branch information
Showing
5 changed files
with
229 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
StringCatalogEnum/Sources/StringCatalogEnumLibrary/Models.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/// Represents the root structure of the xcstrings JSON. | ||
/// This struct is designed to handle various JSON formats, including those | ||
/// generated from SwiftUI and manually added translations. | ||
/// | ||
/// Examples of supported JSON formats: | ||
/// | ||
/// 1. Generated from SwiftUI (no translation added): | ||
/// ``` | ||
/// "Home": {} | ||
/// ``` | ||
/// | ||
/// 2. Generated from SwiftUI, with an English translation: | ||
/// ``` | ||
/// "Login": { | ||
/// "localizations": { | ||
/// "en": { | ||
/// "stringUnit": { | ||
/// "state": "translated", | ||
/// "value": "Login" | ||
/// } | ||
/// } | ||
/// } | ||
/// } | ||
/// ``` | ||
/// | ||
/// 3. Manually added, English only: | ||
/// ``` | ||
/// "welcomeBack": { | ||
/// "extractionState": "manual", | ||
/// "localizations": { | ||
/// "en": { | ||
/// "stringUnit": { | ||
/// "state": "translated", | ||
/// "value": "Welcome back" | ||
/// } | ||
/// } | ||
/// } | ||
/// } | ||
/// ``` | ||
public struct Localizations: Decodable { | ||
public let sourceLanguage: String | ||
public let version: String | ||
public let strings: [String: StringInfo] | ||
} | ||
|
||
public struct StringInfo: Decodable { | ||
public let extractionState: String? | ||
public let localizations: [String: Localization]? | ||
} | ||
|
||
public struct Localization: Decodable { | ||
public let stringUnit: StringUnit? | ||
// let variations: Variations? | ||
} | ||
|
||
// struct Variations: Decodable { | ||
// let plural: PluralVariations? | ||
// let device: DeviceVariations? | ||
// } | ||
|
||
// struct PluralVariations: Decodable { | ||
// let one: StringUnitWrapper? | ||
// let other: StringUnitWrapper? | ||
// } | ||
|
||
// struct DeviceVariations: Decodable { | ||
// let variations: [String: StringUnitWrapper]? | ||
// } | ||
|
||
// struct StringUnitWrapper: Decodable { | ||
// let stringUnit: StringUnit | ||
// } | ||
|
||
public struct StringUnit: Decodable { | ||
public let state: String | ||
public let value: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters