<commit_before>//
//  UIButton+Localization.swift
//  Pods
//
//  Created by <NAME> on 02/01/2017.
//
//

import Foundation

private var localizationKey: UInt8 = 4

extension UIButton {
    /// Localization Key used to reference the unique translation and text required.
    @IBInspectable
    public var LocalizeKey: String? {
        get {
            return objc_getAssociatedObject(self, &localizationKey) as? String
        }
        set(newValue) {
            self.localizaionClear()
            objc_setAssociatedObject(self, &localizationKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
            updateLocalisation()
            localizationSetup();
        }
    }
    
    /// clear previous localization listeners
    func localizaionClear(){
        NotificationCenter.default.removeObserver(self, name: Localization.ALL_CHANGE, object: nil);
        if LocalizeKey != nil && (LocalizeKey?.characters.count)! > 0 {
            let normalKey = "\(self.LocalizeKey!).Normal";
            NotificationCenter.default.removeObserver(self, name: Localization.highlightEvent(localizationKey: normalKey), object: nil);
            NotificationCenter.default.removeObserver(self, name: Localization.localizationEvent(localizationKey: normalKey), object: nil);
        }
    }
    
    /// setup requirements for localization listening
    func localizationSetup(){
        NotificationCenter.default.addObserver(self, selector: #selector(updateLocalizationFromNotification), name: Localization.ALL_CHANGE, object: nil)
        let normalKey = "\(self.LocalizeKey!).Normal";
        NotificationCenter.default.addObserver(self, selector: #selector(localizationHighlight), name: Localization.highlightEvent(localizationKey: normalKey), object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(updateLocalizationFromNotification), name: Localization.localizationEvent(localizationKey: normalKey), object: nil)
    }
    
    /// update localization from notification on main thread
    @objc private func updateLocalizationFromNotification() {
        DispatchQueue.main.async(execute: {
            self.updateLocalisation()
        })
        
    }
    
    /// trigger field highlight
    public func localizationHighlight() {
        /*DispatchQueue.main.async(execute: {
         let originalCGColor = self.layer.backgroundColor
         UIView.animate(withDuration: 0.4, animations: {
         self.layer.backgroundColor = UIColor.red.cgColor
         }, completion: { (okay) in
         UIView.animate(withDuration: 0.4, delay: 0.4, options: UIViewAnimationOptions.curveEaseInOut, animations: {
         self.layer.backgroundColor = originalCGColor
         }, completion: { (complete) in
         
         })
         })
         })*/
    }
    
    /// update the localization
    public func updateLocalisation() {
        if ((self.LocalizeKey?.isEmpty) != nil)  {
            
            let normalText = self.title(for: .normal);
            if normalText != nil && (normalText?.characters.count)! > 0 {
                let normalKey = "\(self.LocalizeKey!).Normal";
                let languageString = Localization.get(normalKey, alternate:normalText!)
                self.setTitle(languageString, for: .normal);
            }
        }
    }
}<commit_msg>update to remove unnecessary UIButton Set<commit_after>//
//  UIButton+Localization.swift
//  Pods
//
//  Created by <NAME> on 02/01/2017.
//
//

import Foundation

private var localizationKey: UInt8 = 4

extension UIButton {
    /// Localization Key used to reference the unique translation and text required.
    @IBInspectable
    public var LocalizeKey: String? {
        get {
            return objc_getAssociatedObject(self, &localizationKey) as? String
        }
        set(newValue) {
            self.localizaionClear()
            objc_setAssociatedObject(self, &localizationKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
            updateLocalisation()
            localizationSetup();
        }
    }
    
    /// clear previous localization listeners
    func localizaionClear(){
        NotificationCenter.default.removeObserver(self, name: Localization.ALL_CHANGE, object: nil);
        if LocalizeKey != nil && (LocalizeKey?.characters.count)! > 0 {
            let normalKey = "\(self.LocalizeKey!).Normal";
            NotificationCenter.default.removeObserver(self, name: Localization.highlightEvent(localizationKey: normalKey), object: nil);
            NotificationCenter.default.removeObserver(self, name: Localization.localizationEvent(localizationKey: normalKey), object: nil);
        }
    }
    
    /// setup requirements for localization listening
    func localizationSetup(){
        NotificationCenter.default.addObserver(self, selector: #selector(updateLocalizationFromNotification), name: Localization.ALL_CHANGE, object: nil)
        let normalKey = "\(self.LocalizeKey!).Normal";
        NotificationCenter.default.addObserver(self, selector: #selector(localizationHighlight), name: Localization.highlightEvent(localizationKey: normalKey), object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(updateLocalizationFromNotification), name: Localization.localizationEvent(localizationKey: normalKey), object: nil)
    }
    
    /// update localization from notification on main thread
    @objc private func updateLocalizationFromNotification() {
        DispatchQueue.main.async(execute: {
            self.updateLocalisation()
        })
        
    }
    
    /// trigger field highlight
    public func localizationHighlight() {
        /*DispatchQueue.main.async(execute: {
         let originalCGColor = self.layer.backgroundColor
         UIView.animate(withDuration: 0.4, animations: {
         self.layer.backgroundColor = UIColor.red.cgColor
         }, completion: { (okay) in
         UIView.animate(withDuration: 0.4, delay: 0.4, options: UIViewAnimationOptions.curveEaseInOut, animations: {
         self.layer.backgroundColor = originalCGColor
         }, completion: { (complete) in
         
         })
         })
         })*/
    }
    
    /// update the localization
    public func updateLocalisation() {
        if ((self.LocalizeKey?.isEmpty) != nil)  {
            
            let normalText = self.title(for: .normal);
            if normalText != nil && (normalText?.characters.count)! > 0 {
                let normalKey = "\(self.LocalizeKey!).Normal";
                let languageString = Localization.get(normalKey, alternate:normalText!)
                if self.title(for: .normal) != languageString {
                    self.setTitle(languageString, for: .normal);
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10165729505770939, 'fraction_numerical': 0.005327019828351583, 'mean_word_length': 2.6873977086743044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5825431', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1728, 'n_words': 373}