Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Localizable.swift
- // AnimatedLivePaper
- //
- // Created by Burak on 4/11/19.
- // Copyright © 2019
- //
- import Foundation
- import UIKit
- protocol Localizable {
- var localized: String { get }
- }
- protocol StoryboardLocalizable {
- var localizationKey: String? { get set }
- }
- extension String: Localizable{
- var localized: String {
- return NSLocalizedString(self, comment: self)
- }
- func localize(_ args: CVarArg...) -> String {
- return String(format: self.localized,arguments: args)
- }
- }
- extension UILabel: StoryboardLocalizable {
- @IBInspectable public var localizationKey: String? {
- get { return nil }
- set(key) {
- text = key?.localized
- }
- }
- }
- extension UIButton: StoryboardLocalizable {
- @IBInspectable public var localizationKey: String? {
- get { return nil }
- set(key) {
- setTitle(key?.localized, for: .normal)
- }
- }
- }
- extension UINavigationItem: StoryboardLocalizable {
- @IBInspectable public var localizationKey: String? {
- get { return nil }
- set(key) {
- title = key?.localized
- }
- }
- }
- extension UIBarItem: StoryboardLocalizable {
- @IBInspectable public var localizationKey: String? {
- get { return nil }
- set(key) {
- title = key?.localized
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement