Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "I don't use localizations (probably because there are about 30 language files)" I still didn't understood that.
- But I'd go with:
- protocol Translations {
- var valid_email: String { get }
- }
- struct German: Translations {
- var valid_email: String = "Bitte geben Sie eine gültige e-mail Adresse ein"
- }
- struct English: Translations {
- var valid_email: String = ""
- }
- extension Locale {
- static func isGerman() -> Bool {
- return Locale.preferredLanguages[0].range(of:"de") != nil
- }
- static func language() -> Translations {
- if isGerman() {
- return German()
- }
- return English()
- }
- }
- let errorLabel = UILabel()
- errorLabel.text = Locale.language().valid_email
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement