Last active
October 8, 2015 10:06
-
-
Save alsedi/357c99ff6d138cf94804 to your computer and use it in GitHub Desktop.
Localization of String, Int, Float, etc (Swift)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: https://gist.github.com/alsedi/357c99ff6d138cf94804 | |
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