SHARE
TWEET

Localizable

itamar00 Jan 24th, 2020 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  Project.swift
  3. //  Created by Itamar Sousa Silva on 12/07/18.
  4. //
  5.  
  6. import Foundation
  7. import UIKit
  8.  
  9. /*
  10.  Todas as strings estão mapeadas aqui.
  11.  Caso adicione algum texto no projeto verifique se já não existe.
  12.  O app até o momento não será internalizando, mas caso seja, basta mudar o Localizable.strings para o idioma desejado.
  13.  */
  14.  
  15. // MARK: - Project Constants
  16. enum Project {
  17.    
  18.     // Image Names
  19.     enum Images {
  20.         //        enum Checkout: String, ImageRepresentable {
  21.         //            case first  = "icon-first-image"
  22.         //            case second = "icon-second-image"
  23.         //        }
  24.     }
  25.    
  26.     // Localizable Strings
  27.     enum Localizable {
  28.        
  29.         enum Commom: String, LocalizeRepresentable {
  30.             case email          = "commom.email"
  31.             case password       = "commom.password"
  32.         }
  33.        
  34.         enum Buttons: String, LocalizeRepresentable {
  35.             case login          = "buttons.login"
  36.         }
  37.        
  38.         enum Title: String, LocalizeRepresentable {
  39.             case login          = "title.login"
  40.             case enterprises    = "title.enterprises"
  41.         }
  42.        
  43.     }
  44. }
  45.  
  46.  
  47. // MARK: - Representable Protocols
  48. protocol ImageRepresentable: RawRepresentable {
  49.     var image: UIImage? { get }
  50. }
  51.  
  52. protocol LocalizeRepresentable: RawRepresentable {
  53.     var localized: String { get }
  54. }
  55.  
  56.  
  57. // MARK: - Representable Protocols Extensions
  58. extension ImageRepresentable where RawValue == String {
  59.     var image: UIImage? {
  60.         return UIImage(named: rawValue)
  61.     }
  62. }
  63.  
  64. extension LocalizeRepresentable where RawValue == String {
  65.     var localized: String {
  66.         return NSLocalizedString(rawValue, comment: "")
  67.     }
  68. }
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