Skip to content

Instantly share code, notes, and snippets.

Damijan Račel damijanracel

Block or report user

Report or block damijanracel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

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:

@damijanracel
damijanracel / FormatSpecifiers.swift
Last active Oct 16, 2018
Localization with format specifiers
View FormatSpecifiers.swift
label.text = String(format: LocalizationKey.bye.string, name)
@damijanracel
damijanracel / Usage.swift
Last active Oct 16, 2018
Enum with parameters usage
View Usage.swift
label.text = LocalizationKey.progress(10, 1)
@damijanracel
damijanracel / TestingLocalization.swift
Created Oct 11, 2018
Testing localization example
View TestingLocalization.swift
func testLabel_Should_SetCorrectLocalizationKey() {
XCTAssertEqual(mainViewController!.label.localizationKey, LocalizationKey.bye)
}
@damijanracel
damijanracel / LocalizationStruct.swift
Created Oct 11, 2018
Localization struct upgrade
View LocalizationStruct.swift
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 {
@damijanracel
damijanracel / LocalizedLabel.swift
Created Oct 11, 2018
Localized label for struct
View LocalizedLabel.swift
class LocalizedLabel: UILabel {
var localizationKey: LocalizationKey?
func set(key localization: Localization) {
self.text = localization.string
self.localizationKey = localization.key
}
}
View Localizable.string
"hello" = "hello";
"bye" = "bye %@";
"progress" = "Finished %d of %d";
View LocalizationStruct.swift
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))
}
@damijanracel
damijanracel / UILabelLocalizationExtension.swift
Created Oct 9, 2018
UILabel extension for localization
View UILabelLocalizationExtension.swift
extension UILabel {
func set(key: LocalizationKey) {
localizationKey = key
text = key.string
}
private struct AssociatedKeys {
static var localizationKey = "nsh_localizationKey"
}
You can’t perform that action at this time.