Reputation: 7068
For some weird reason only part of the texts in the Localizable.strings translates properly. If the string contain more the 1 word (the english side), it won't be translated. I made sure it is the same string (copied and pasted)
"Login" = "כניסה"; //translates properly
"Email" = "דואר אלקטרוני"; //translates properly
"Password" = "סיסמא"; //translates properly
"forgot password?" = "שכחת סיסמא?"; //translation does not work
"Sign up" = "הירשם"; //translation does not work
I use this extension:
extension String {
var localized: String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: "")
}
}
and in the code:
override func viewDidLoad() {
super.viewDidLoad()
self.emailTextField.placeholder = "Email".localized
self.passwordTextField.placeholder = "Password".localized
self.loginButton.setTitle("Login".localized, for: .normal)
self.signupButton.setTitle("Sign up".localized, for: .normal)
self.forgetPasswordButton.setTitle("forgot password?", for: .normal)
}
Upvotes: 1
Views: 462
Reputation: 36640
Based on the appearance of Sign up having an underline, it looks like you have an NSAttributedString
, which you then confirmed in your follow up comment.
While your code section here for "forgot password?" does not include the localize
call you use elsewhere in your viewDidLoad
, it turns out that you also identified this as an attributed string.
self.forgetPasswordButton.setTitle("forgot password?", for: .normal)
As you noted in your comment, this was corrected by applying the localization to the attributed string:
let attributeString = NSMutableAttributedString(string: "Sign up".localized,
attributes: yourAttributes)
self.signupButton.setAttributedTitle(attributeString, for: .normal)
Upvotes: 1