Caro
Caro

Reputation: 511

can I localize strings directly in an iOS storyboard without using code?

I have a really simple Startscreen in the storyboard with a UILabel and a Button. No classfiles are yet needed and would like to avoid having two extra files just for setting one UILabel in viewdidload.

Is there a way to set the Label directly in the storyboard? Like for example select the UILabel and write in the title tab NSLocalizedString(@"startlabel", nil) ?

Many thanks in advance for your help

Upvotes: 4

Views: 1999

Answers (1)

Oleg
Oleg

Reputation: 3014

You can create outlets for UILabel and UIButton and then programatically change titles:

myLabel.text = NSLocalizedString(@"startlabel", "start label");
[myButton setTitle:NSLocalizedString(@"startButton", "start button") forState: UIControlStateNormal];

and don't forget to create Localizable.strings files where you can specify your translations

Upvotes: 3

Related Questions