Instantly share code, notes, and snippets.

What would you like to do?
Localization of String, Int, Float, etc (Swift)
import Foundation
// Usage "String".localize will search for "String" key in Localizeble
// Works for all types that conform CustomStringConvertible protocol, e.g. Int, Float.
// Raw value will be converted to string and used as key, e.g.
// 10.localize, will search for "10" key.
// If key not exists, then string value will be returned
// Gist:
extension CustomStringConvertible {
var localize: String {
return NSLocalizedString(self.description, comment: "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment