Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS storyboard localization for new UI

I use Xcode 5 in a project. and the project need to localization. Xcode had help me generated Localizable.strings it looks like

/* Class = "IBUIButton"; normalTitle = "2013-10-1"; ObjectID = "p5u-h7-pfJ"; */
"p5u-h7-pfJ.normalTitle" = "2013-10-1";

/* Class = "IBUILabel"; text = "Label"; ObjectID = "pBS-eN-YUz"; */
"pBS-eN-YUz.text" = "Label";

/* Class = "IBUITextField"; placeholder = "Input Name Here"; ObjectID = "pE4-WG-fPp"; */
"pE4-WG-fPp.placeholder" = "Input Name Here";

/* Class = "IBUILabel"; text = "Detail"; ObjectID = "qSu-Mo-baT"; */
"qSu-Mo-baT.text" = "Detail";

but how should I do if I want to add new UI in the storyboard. How can I add new key-value?

like image 227
bohan Avatar asked Dec 20 '13 09:12

bohan


People also ask

How do I localize Xib files?

Right click on the xib file in Xcode, and choose Get Info . Select the General tab and on the bottom click Make File Localizable . Then you will be able to add localizations by clicking Add Localization on that same tab. I would recommend this tutorial for step-by-step information (and pretty pictures).

What is localized string key Swiftui?

The key used to look up an entry in a strings file or strings dictionary file.


2 Answers

In your storyboard, every single Object has an ID. In the 'Utilities' view, 'Identity Inspector' thumb, 'Document' section, there is a field 'Object ID'

I've never used this, but I guess that, if you have a label with ID 141-wB-KQD and you want to set its text property, you have to put in your Localizable.strings :

"141-wB-KQD.text" = "the value you want";
like image 62
zbMax Avatar answered Sep 19 '22 10:09

zbMax


  1. Make backup copies of a storyboard's .strings file for a locale that needs to be updated.

  2. Select storyboard in the Project Navigator (in the left Xcode's pane), open File Inspector (right pane) and unmark checkbox for that locale.

  3. In the 'Do you want to remove...' alert appeared, check 'Delete localized resource files from disk' checkbox and press 'Remove' button.

  4. Mark back the same checkbox; this will generate localized resource file for the locale; it will contain entries for all objects including newly added but its contents will not be localized at all.

  5. Merge this newly generated file with saved backup - this will restore all localizations you've done before.

  6. Localize new objects.

like image 26
Nikolay Mamaev Avatar answered Sep 18 '22 10:09

Nikolay Mamaev