Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: Localization in Storyboard - Labels not added to Main.strings?

When I try to localize my app and I create a new Main.strings file for the target language, everything I have created in interface builder (labels, buttons, ...) is added to the new Main.strings files (base and language versions) and I can localize the text accordingly.

But when I later add a label or a button to a ViewController in interface builder, it is not automatically added to the Main.strings files for the base and language version.

So, how can I find out what the ObjectID for the button/label is so that I can add it to the strings files?

Or is there another way to force Xcode to add newly added labels and buttons to those files automatically?

like image 684
RjC Avatar asked Jan 13 '18 12:01

RjC


People also ask

How to change localization in Xcode?

To do this, in Xcode, select Product > Scheme > Manage Schemes ... Then in the Run/debug tab, change the "Application Language" to your desired language. And now every time you build and run your app from Xcode, it will use that language as the preferred language.


2 Answers

After selecting UILabel from storyboard, You can find object id of UILabel in right panel:

enter image description here

Then you can set text of label as below in your Main.string file:

"sxl-NO-5WX.text" = "Phone";
like image 71
Dhaval Bhimani Avatar answered Nov 07 '22 19:11

Dhaval Bhimani


Easy XIB and Storyboard Localization - Very efficient and simple method

This repository serves as an example on how to localize some UIKit controls:

UILabel, UIButton, UITextField placeholder, UISegmentedControl, UIBarItem for tab bar items and navigation bar items, UINavigationItem, Review Localizable.swift to check it.

https://github.com/emenegro/xib-localization

English

Spanish

like image 42
Gourav Mandliya Avatar answered Nov 07 '22 20:11

Gourav Mandliya