Created
November 8, 2024 22:08
-
-
Save delasign/18c2a4e5b80b1fbf6854ea14ac049315 to your computer and use it in GitHub Desktop.
Updated gatherLanguageContent for our language coordinator to work with Swift Testing
This file contains hidden or 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
private func gatherLanguageContent(langugeCode: String) -> UIContent? { | |
debugPrint("\(LanguageCoordinator.identifier) gatherLanguageContent \(DebuggingIdentifiers.actionOrEventInProgress) Generating Content for : \(langugeCode)") | |
let path: String? | |
if isTestEnvironment { | |
path = Bundle(for: type(of: self)).path(forResource: languageCode, ofType: "json") | |
} else { | |
path = Bundle.main.path(forResource: langugeCode, ofType: "json") | |
} | |
guard let languageJSON = path else { | |
debugPrint("\(LanguageCoordinator.identifier) gatherLanguageContent \(DebuggingIdentifiers.actionOrEventFailed) Failed to gather Content: path does nto exist") | |
return nil | |
} | |
do { | |
let jsondata = try Data(contentsOf: URL(fileURLWithPath: languageJSON), options: .mappedIfSafe) | |
let data = try JSONDecoder().decode(UIContent.self, from: jsondata) | |
debugPrint("\(LanguageCoordinator.identifier) gatherLanguageContent \(DebuggingIdentifiers.actionOrEventSucceded) Generated Content for : \(langugeCode)") | |
return data | |
} catch { | |
debugPrint("\(LanguageCoordinator.identifier) gatherLanguageContent \(DebuggingIdentifiers.actionOrEventFailed) Failed to gather Content for : \(langugeCode)") | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment