Localization can go a long way towards increasing the sales of our apps. Users are browsing the App Store all over the world, and when they come across a neat looking app that's not translated into their language, they're very likely to keep on scrolling. Today we’ll check out a library called Localize-Swift from Roy Marmelstein that makes this process much nicer.
The first helpful addition Localize-Swift brings us is a better way to localize our strings:
searchBar.placeholder = "Hello World".localized()
Then we can easily test our translations at runtime using:
We can respond to language changes using an NSNotification:
NSNotificationCenter.defaultCenter().addObserver( self, selector: "setText", name: LCLLanguageChangeNotification, object: nil )
Localize-Swift also provides a custom
genstrings.py script to easily fill our
.strings files even though we're not using NSLocalizedString directly, neat!
More info about Localize-Swift can be found at git.io/localizeswift