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?
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.
After selecting UILabel
from storyboard, You can find object id of UILabel
in right panel:
Then you can set text of label as below in your Main.string
file:
"sxl-NO-5WX.text" = "Phone";
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With