- Getting the
signInButton
value fromCommon.strings
file.
Strings.Common.signInButton.localized
protocol Localizable { | |
var localized: String { get } | |
static var tableName: String { get } | |
} | |
// MARK: - RawRepresentable | |
extension Localizable where Self: RawRepresentable, Self.RawValue == String { | |
var localized: String { | |
return rawValue.localized(bundle: .main, tableName: Self.tableName) | |
} | |
static var tableName: String { | |
return String(describing: self) | |
} | |
} |
extension String { | |
func localized(bundle: Bundle, tableName: String) -> String { | |
return NSLocalizedString(self, tableName: tableName, bundle: bundle, value: "**\(self)**", comment: "") | |
} | |
} |
enum Strings { | |
// Mirror of: `Common.strings` | |
enum Common: String, Localizable { | |
case signInButton = "SIGN_IN" | |
} | |
// Mirror of: `Card.strings` | |
enum Card: String, Localizable { | |
case title = "TITLE" | |
case description = "DESCRIPTION" | |
} | |
} |