Last active
April 13, 2019 18:11
-
-
Save popcornomnom/0fb434a7cc54dee82c14b030ff81ce49 to your computer and use it in GitHub Desktop.
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
protocol LocalizableDelegate { | |
var rawValue: String { get } //localize key | |
var table: String? { get } | |
var localized: String { get } | |
} | |
extension LocalizableDelegate { | |
//returns a localized value by specified key located in the specified table | |
var localized: String { | |
return Bundle.main.localizedString(forKey: rawValue, value: nil, table: table) | |
} | |
// file name, where to find the localized key | |
// by default is the Localizable.string table | |
var table: String? { | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment