Vignesh J
Vignesh J

Reputation: 21

How to Change the Language in Alert view using NSLocalizedString

When I am using in this line

alertView.message=NSLocalizedString("Please_enter_all_fields",comment:"Please_enter_all_fields")

alert pop up messages shows Please_enter_all_fields, but I was declared the Localized.string file: Please_enter_all_fields="Please enter all fields". How can I display the alert message related declared String of Localized.string variables?

Upvotes: 1

Views: 973

Answers (2)

Willjay
Willjay

Reputation: 6469

let title = NSLocalizedString("TITLE", comment: "TITLE") 
let msg = NSLocalizedString("Please_enter_all_fields", comment: "Please_enter_all_fields")

let alert = UIAlertController.init(title: title, message: msg, preferredStyle: .alert)

The NSLocalizedString is default as "English - Development Language".

you can just define the value as you want

let msg = NSLocalizedString("Please enter all fields", comment: "Please enter all fields")

enter image description here

Or you have to add "English" Localisations, and translate inside "Localizable.String(English(United States))"

enter image description here

/* Please_enter_all_fields */
"Please_enter_all_fields" = "Please enter all fields";

Upvotes: 2

oozoofrog
oozoofrog

Reputation: 166

may be this is wrong

Please_enter_all_fields="Please enter all fields"

It's must be setting like below:

"Please_enter_all_fields"="Please enter all fields";

Upvotes: 2

Related Questions