Skip to content

Instantly share code, notes, and snippets.

@popcornomnom
Last active April 13, 2019 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popcornomnom/0fb434a7cc54dee82c14b030ff81ce49 to your computer and use it in GitHub Desktop.
Save popcornomnom/0fb434a7cc54dee82c14b030ff81ce49 to your computer and use it in GitHub Desktop.
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