I hereby claim:
- I am damijanracel on github.
- I am maishu (https://keybase.io/maishu) on keybase.
- I have a public key ASCmxxCQDHnV-oY5wDvy6YI__vkzajzNbHQKrJaVbcFa_Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| label.text = String(format: LocalizationKey.bye.string, name) |
| “hello”.localized() |
| label.text = LocalizationKey.progress(10, 1) |
| func testLabel_Should_SetCorrectLocalizationKey() { | |
| XCTAssertEqual(mainViewController!.label.localizationKey, LocalizationKey.bye) | |
| } |
| 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 { |
| class LocalizedLabel: UILabel { | |
| var localizationKey: LocalizationKey? | |
| func set(key localization: Localization) { | |
| self.text = localization.string | |
| self.localizationKey = localization.key | |
| } | |
| } |
| "hello" = "hello"; | |
| "bye" = "bye %@"; | |
| "progress" = "Finished %d of %d"; |
| struct Localization { | |
| let string: String | |
| private init(string: String) { | |
| self.string = string | |
| } | |
| static func bye(name: String) -> Localization { | |
| return Localization(string: String(format: LocalizationKey.bye.string, name)) | |
| } |
| extension UILabel { | |
| func set(key: LocalizationKey) { | |
| localizationKey = key | |
| text = key.string | |
| } | |
| private struct AssociatedKeys { | |
| static var localizationKey = "nsh_localizationKey" | |
| } |