Demystifying NSLocalizedString and genstrings

NSLocalizedString and genstrings make it very easy to generate a Localizable.strings file for your app. However, the steps that they follow to generate the file are easy and worthwhile to understand. You can do all of this yourself.

A strings file is just a collection of key-value pairs. The key and the value are strings surrounded by quotes, and the pair is terminated with a semicolon:

"​K​e​y​1​"​ ​=​ ​"​V​a​l​u​e​1​"​;​
"​K​e​y​2​"​ ​=​ ​"​V​a​l​u​e​2​"​;​

You can create a strings file yourself and add it to your project just by dragging it into Xcode. Once you have added the file, you can create localizations of it for other languages using the file inspector.

Once you have ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.