Last active
January 8, 2023 03:03
-
-
Save AmrAbedal/4a8be2fedd13c3217698752db3a25bf9 to your computer and use it in GitHub Desktop.
iOS XIB Localization tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Welcome_back"="Welcome back"; | |
"PromoCodeAmount"="You have a promo code for %d %@"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension String { | |
var localized: String { | |
return NSLocalizedString(self, comment: "") | |
} | |
func getLocalized(arg: CVarArg...) -> String { | |
return String.init(format: self.localized,arguments: arg) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UILabel { | |
@IBInspectable | |
var localizedTextKey: String { | |
set{ | |
self.text = newValue.localized | |
} | |
get{ | |
return text ?? "" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UITextField { | |
@IBInspectable | |
var KeyPlaceholder: String { | |
set{ | |
self.placeholder = newValue.localized | |
} | |
get{ | |
return placeholder ?? "" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment