Last active
October 24, 2017 18:48
-
-
Save jonathan-beebe/a8e38daff9364f4e6447ef1d1293acc1 to your computer and use it in GitHub Desktop.
Localizable views in xib or storyboards
This file contains hidden or 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 UIKit | |
| /// Implements a UILabel that can be localized within a xib or storyboard. | |
| /// To render a localized string set a “User defined runtime attribute” on | |
| /// the view with a key path of `localizableStringKey` and a string value of | |
| /// the localized string key. | |
| class LocalizableLabel: UILabel { | |
| var localizableStringKey: String? { | |
| didSet { | |
| if let key = localizableStringKey { | |
| text = LocStr(key) | |
| } | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
trying out the suggestion here: http://stackoverflow.com/a/7413783/123781
Of course we could just use Base Internationalization but I wanted to get a feel for how this method worked.