Skip to content

Instantly share code, notes, and snippets.

View r3dm4n's full-sized avatar

Alexandru Corut r3dm4n

View GitHub Profile
@thefotes
thefotes / localized.swift
Created January 17, 2016 13:33
Cleaner localized strings with Swift protocols and enums.
import Foundation
// Localized string struct that has single static method which accepts a `Localizeable` value.
struct LocalizedString {
// Usage: LocalizedString.localizedStringForValue(NavBarTitle.Home)
static func localizedStringForValue<T: Localizeable>(localizeableValue: T) -> String {
return NSLocalizedString(localizeableValue.localizedString, comment: localizeableValue.localizedStringComment)