Localization of the iOS storyboard for the new user interface

I am using Xcode 5 in a project. and the project needs localization. Xcode helped me generate 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 do I do it if I want to add a new interface to the storyboard. How to add a new key value?

+7
ios xcode localization storyboard
source share
4 answers

In your storyboard, each object has an identifier. In the Utilities, Identifier Index, Document section, there is an Object Identifier field

I never used this, but I assume that if you have a label with the identifier 141-wB-KQD and you want to set its text property, you should put in your Localizable.strings :

 "141-wB-KQD.text" = "the value you want"; 
+18
source share
  • Back up the storyboard .strings file for the locale you want to update.

  • Select the storyboard in the Project Navigator (in the left pane of Xcode), open the “File Inspector” (right pane) and check the box for this locale.

  • In the warning message “You want to delete ...”, check the box “Delete localized resource files from disk” and click the “Delete” button.

  • Check the same box; this will create a localized resource file for the locale; it will contain records for all objects, including recently added ones, but its contents will not be localized at all.

  • Combining this newly created file with the saved backup copy will restore all previously done localizations.

  • Locate new objects.

+2
source share

Not sure if this is the “right” way or the best way, but here is what I am doing:

1) do any localization of LAST. In other words, first try to make sure you don’t need the changes made to the base storyboard. It may sound like a cop, but it’s actually the best way to avoid trouble.

2), since it’s not always how everything turns out, if you need to make changes, you can push them into localized files by changing them from “lines” to “storyboard” and then back. This will automatically save your existing translations and will work in any new material, and therefore is better than directly deleting localized files from the package.

I noticed that this may leave some redundant lines in the localized file from time to time, and sometimes they need to be deleted manually or it will not compile correctly, but if there is a better way to do this, I like to know myself.

+1
source share

If you want to localize your project views, just go to the storyboard, click on the view controller, then go to File Inspector and click “Locate” ... you will have one storyboard file for each language.

-one
source share

All Articles