Last active
March 10, 2019 21:15
-
-
Save klein-artur/ee9213af8242ac28ac75f1c83e57c9d8 to your computer and use it in GitHub Desktop.
Simple way to localize your String. I don't know why, but somehow I hate alway entering this NSLocalizedString methods. Do your stuff easy with this extension by just "localize your string".localize()
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
extension String { | |
func localize() -> String { | |
return NSLocalizedString(self, comment: "") | |
} | |
func localize(_ args: CVarArg...) -> String { | |
return String(format: NSLocalizedString(self, comment: ""), args) | |
} | |
} | |
func localizeSomeString() { | |
"This is the localization key".localize() | |
"This %@ should be localized in %@ languages.".localized("string", 4) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment