SHARE
TWEET

Untitled

a guest Sep 20th, 2019 131 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "I don't use localizations (probably because there are about 30 language files)" I still didn't understood that.
  2. But I'd go with:
  3.  
  4.  
  5. protocol Translations {
  6.     var valid_email: String { get }
  7. }
  8.  
  9. struct German: Translations {
  10.     var valid_email: String = "Bitte geben Sie eine g├╝ltige e-mail Adresse ein"
  11. }
  12.  
  13. struct English: Translations {
  14.     var valid_email: String = ""
  15. }
  16.  
  17. extension Locale {
  18.     static func isGerman() -> Bool {
  19.         return Locale.preferredLanguages[0].range(of:"de") != nil
  20.     }
  21.  
  22.     static func language() -> Translations {
  23.         if isGerman() {
  24.             return German()
  25.         }
  26.         return English()
  27.     }
  28. }
  29.  
  30. let errorLabel = UILabel()
  31. errorLabel.text = Locale.language().valid_email
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top