Graphics Programs Reference
In-Depth Information
Localizing Resources
When internationalizing, you ask the instance of
NSLocale
questions. But the
NSLocale
only has a few region-specific variables. This is where localization comes into
play: Localization is the process by which application-specific substitutions are created for
different region and language settings. Localization usually means one of two things:
• generating multiple copies of resources like images, sounds, and interfaces for dif-
ferent regions and languages
• creating and accessing
strings tables
to translate text into different languages
Any resource, whether it's an image or a XIB file, can be localized. Localizing a resource
puts another copy of the resource in the application bundle. These resources are organized
into language-specific directories, known as
lproj
directories. Each one of these director-
ies is the name of the localization suffixed with
lproj
. For example, the American Eng-
lish localization is
en_US
: where
en
is the English language code and
US
is the United
States of America region code. (The region can be omitted if you don't need to make re-
gional distinctions in your resource files.) These language and region codes are standard on
all platforms, not just iOS.
When a bundle is asked for the path of a resource file, it first looks at the root level of the
bundle for a file of that name. If it does not find one, it looks at the locale and language set-
tings of the device, finds the appropriate
lproj
directory, and looks for the file there.
Thus, just by localizing resource files, your application will automatically load the correct
file.
In this section, you're going to localize one of
Homepwner
's interfaces: the
De-
tailViewController.xib
file. You will create English and Spanish localizations,
which will create two
lproj
directories that will each contain a version of
De-
tailViewController.xib
. Select
DetailViewController.xib
in the project
navigator. Then, show the utilities area.
Click the icon in the inspector selector to open the file inspector. Find the section in this
inspector named
Localization
and click the
+
button at the bottom. This signifies to
Xcode