background image
C H A P T E R 2 0
Localizing Newton Applications
20-8
Using the Localization Features of the Newton
In the preceding code example the
myLocaleBundle
frame is based on the U.S.
locale bundle. It gives a new
title
and
localeSym
value, as it must, but
implements no functional changes to the locale. To make changes to the locale
bundle, you can add your own slots in place of the comment that says
// add slots to be modified
Your custom locale bundle must have a
localeSym
slot of its own, as well as a
title
slot that gives the string that you want to appear in the Country pop-up
menu. Since there can't be another locale bundle in the system with the same
symbol as your new bundle, and shouldn't be one with the same title, be careful to
avoid name clashes when creating your bundle's
title
and
localeSym
values.
The problems associated with creating a unique name string for a locale bundle are
similar to those you might encounter when creating a name for a soup; for
suggestions regarding the creation of unique name strings, see "Naming Soups"
(page 11-32). Basically, you should incorporate your developer or application
symbol in the bundle's title and symbol slots.
Adding a New Bundle to the System
20
Once you have created a locale bundle, you need to make it available to the system
by using the
AddLocale
function. The following code sample shows how to pass
the previously created locale bundle
myLocaleBundle
to this function:
Call kAddLocaleFunc with (myLocaleBundle);
(You call this function in this way because it is a platform file function.)
If the
localeSym
slot in
myLocaleBundle
is not unique, the new locale
overrides the existing locale with the same symbol. You can override a built-in
locale bundle.
Removing a Locale Bundle
20
To remove the custom locale bundle you have installed use the system-supplied
RemoveLocale
function.
As with any shared data, the appropriate time to remove your locale bundle is left
up to you because it can be difficult to determine whether other applications are
using a bundle. Even if your own application is the only one using the custom
locale bundle, it can be difficult to decide whether to remove it. You wouldn't
necessarily want to install it every time the application opened and remove it every
time the application closed.
If you remove the active locale bundle,
RemoveLocale
makes one of the built-in
locales the active locale; the locale it chooses depends on the ROM version. If your
application makes a new bundle active, you may want to save the symbol of the
previously active bundle, so that you can reset the value before you remove your
locale bundle.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна