Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Localizing string resources

In addition to nib text, text in your application that you intend on showing the user needs to be localized as well. For example, the Action Sheet used in iBountyHunter offers the user the option to take a photo, choose an existing one, or cancel. That button text is generated programmatically and needs to be translated appropriately.

For this type of text, called string resources, the iOS uses strings files. You’ll generally have one of these files for each language you support. Each file contains a description of what the string is trying to communicate, the default language version of the string, and the translated version, like this:

image with no caption

Generating your strings file

You could create your strings file by hand, but a much simpler way is to have Xcode generate it for you. Xcode does this by looking for the localization macros that load the translated text. To support localized strings, you should use one of the NSLocalizedString macros, like this:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint