13

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?

RjC
  • 827
  • 2
  • 14
  • 33
  • Possible duplicate of [Is it possible to update a localized storyboard's strings?](https://stackoverflow.com/questions/15094259/is-it-possible-to-update-a-localized-storyboards-strings) – Shehata Gamal Jan 13 '18 at 13:24

5 Answers5

26

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";
Dhaval Bhimani
  • 980
  • 1
  • 13
  • 24
2

Dhaval Bhimani's answer is the easiest solution for localizing a small number of newly added view components. If you want to regenerate all the localizations for a storyboard, select the Main.storyboard-> deselect the localization check boxes for all the languages. check the 'Delete localized resource files from disk' check box enter image description here now make sure your newly added labels and buttons are there and localize again by selecting languages. Just in case backup your string files before that

EarlySun
  • 185
  • 2
  • 12
1

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

0

Use ibtool to extract the strings in your storyboard.

Open the Terminal application Locate your Base.lproj directory Use this line to extract the strings:

ibtool MainStoryboard.storyboard --generate-strings-file file_name.strings

After ibtool extracts the strings to file_name.strings, you can copy and paste it to your original .strings file

(Originally appread here Is it possible to update a localized storyboard's strings?)

katie
  • 1
0

Use ObjectID.text for UILabel

Use ObjectID.normalTitle for UIButton

Example:

/* Object ID of UILabel */
"GWb-TZ-iGk.text" = "I am label";

/* Object ID of UIButton */
"H6f-pG-K8Z.normalTitle" = "I am button";
Mohammad Zaid Pathan
  • 16,304
  • 7
  • 99
  • 130