Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Beginning iOS5 Development.pdf
Скачиваний:
7
Добавлен:
09.05.2015
Размер:
15.6 Mб
Скачать

CHAPTER 21: Application Localization

703

Localizing the App Display Name

We want to show you one final piece of localization that is commonly used: localizing the app name that’s visible on the home screen and elsewhere. Apple does this for several of the built-in apps, and you might want to do so as well.

The app name used for display is stored in your app’s Info.plist file, which, in our case, is actually named LocalizeMe-Info.plist. You’ll find it in the Supporting Files folder. Select this file for editing, and you’ll see that one of the items it contains, Bundle display name, is currently set to ${PRODUCT_NAME}.

In the syntax used by Info.plist files, anything starting with a dollar sign is subject to variable substitution. In this case, this means that when Xcode compiles the app, the value of this item will be replaced with the name of the product in this Xcode project, which is the name of the app itself. This is where we want to do some localization, replacing ${PRODUCT_NAME} with the localized name for each language. However, as it turns out, this doesn’t quite work out as simply as you might expect.

The Info.plist file is sort of a special case, and it isn’t meant to be localized. Instead, if you want to localize the content of Info.plist, you need to make localized versions of a file named InfoPlist.strings. Fortunately, that file is already included in every project Xcode creates, so all we need to do is localize it.

Look in the Supporting Files folder and find the InfoPlist.strings file. Use the file inspector’s Localizations section to create a French localization using the same steps you did for the previous localizations (it starts off with an English version located in the en.lproj folder).

Now, we want to add a line to define the display name for the app. In the LocalizeMeInfo.plist file, we were shown the display name associated with a dictionary key called Bundle display name, but that’s not the real key name! It’s merely an Xcode nicety, trying to give a more friendly and readable name. The real name is

CFBundleDisplayName, which you can verify by selecting LocalizeMe-Info.plist, rightclicking anywhere in the view, and selecting Show Raw Keys/Values. This shows you the true names of the keys in use.

So, select the English localization of InfoPlist.strings, and add the following line:

CFBundleDisplayName = "Localize Me";

Now, select the French localization of the InfoPlist.strings file. Edit the file to give the app a proper French name:

CFBundleDisplayName = "Localisez Moi";

If you build and run the app in the simulator right now, you may not see the new name. iOS seems to cache this information when a new app is added, but doesn’t necessarily change it when an existing app is replaced by a new version—at least not when Xcode is doing the replacing. So, if you’re running the simulator in French but you don’t see the

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]