marmelroy / Localize-Swift

Swift friendly localization and i18n with in-app language switching
MIT License
3.08k stars 330 forks source link

Part of the UI control localizeKey is missing. #155

Open CainLuo opened 3 years ago

CainLuo commented 3 years ago
// MARK: UITextField
@IBDesignable public extension UITextField {
    @IBInspectable var placeholderLocalizeKey: String {
        set {
            DispatchQueue.main.async {
                self.placeholder = newValue.localized()
            }
        }
        get {
            return self.placeholderLocalizeKey.localized()
        }
    }
}

// MARK: UIBarButtonItem
@IBDesignable public extension UIBarButtonItem {
    @IBInspectable var localizeKey: String {
        set {
            DispatchQueue.main.async {
                self.title = newValue.localized()
            }
        }
        get {
            return self.localizeKey.localized()
        }
    }
}

Part of the UI control localizeKey is missing, the code is above, can we add it in the next version?

And is there something unreasonable about the localizeKey setting of the UIButton? For example, I need to set the localizeKey for UIButton's highlighted state, which is not provided.

CainLuo commented 3 years ago
// MARK: UIBarButtonItem
@IBDesignable public extension UIViewController {
    @IBInspectable var localizeKey: String {
        set {
            DispatchQueue.main.async {
                self.title = newValue.localized()
            }
        }
        get {
            return self.localizeKey.localized()
        }
    }
}
CainLuo commented 3 years ago

@marmelroy