Skip to content

Instantly share code, notes, and snippets.

@damijanracel
Created October 11, 2018 14:40
Show Gist options
  • Save damijanracel/51590f14e36287f825b3e6dd0ca9e98f to your computer and use it in GitHub Desktop.
Save damijanracel/51590f14e36287f825b3e6dd0ca9e98f to your computer and use it in GitHub Desktop.
Localization struct upgrade
struct Localization {
let key: LocalizationKey
let string: String
private init(string: String, key: LocalizationKey) {
self.string = string
self.key = key
}
static func bye(name: String) -> Localization {
return Localization(string: String(format: LocalizationKey.bye.string, name), key: .bye)
}
static func hello() -> Localization {
return Localization(string: LocalizationKey.hello.string, key: .hello)
}
static func progress(from: Int, to: Int) -> Localization {
return Localization(string: String(format: LocalizationKey.progress.string, from, to), key: .progress)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment