-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codegen: Handle string catalogue files (WIP). #49
- Loading branch information
Showing
3 changed files
with
75 additions
and
3 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
struct StringCatalog: Decodable { | ||
let sourceLanguage: String | ||
let strings: [String: StringCatalogEntry] | ||
} | ||
|
||
struct StringCatalogEntry: Decodable { | ||
let comment: String? | ||
let localizations: [String: Localization]? | ||
} | ||
|
||
struct Localization: Decodable { | ||
let stringUnit: StringUnit? | ||
let variations: Variations? | ||
} | ||
|
||
struct Variations: Decodable { | ||
let plural: PluralVariation? | ||
} | ||
|
||
struct PluralVariation: Decodable { | ||
let zero: Variation? | ||
let one: Variation? | ||
let two: Variation? | ||
let few: Variation? | ||
let many: Variation? | ||
let other: Variation | ||
|
||
var all: [Variation] { [zero, one, two, few, many, other].compactMap { $0 } } | ||
} | ||
|
||
struct Variation: Decodable { | ||
|
||
enum TranslationState: Decodable { | ||
case translated | ||
case needs_review | ||
} | ||
|
||
let stringUnit: StringUnit | ||
let state: TranslationState | ||
} | ||
|
||
struct StringUnit: Decodable { | ||
let value: String | ||
} |