beautypg.com

Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 736

background image

C H A P T E R 2 0

Localizing Newton Applications

20-4

Using the Localization Features of the Newton

Defining a Localization Frame

20

You define the alternative language frames with the

SetLocalizationFrame

function in a text file included in the project. Here is an example:

SetLocalizationFrame({

Swedish: {

find: {

searchFor:

"Söker efter ^0…",

// "Searching for ^0…"

. . .}},

French: {

find: {

searchFor:

"Recherche dans ^0…",// "Searching for ^0…"

. . .}}

});

When the Language setting in the Project Settings dialog box is English, NTK uses
the string included in the code itself (“Searching for name”). When the Language
setting is Swedish, NTK looks for the string contained in the slot

Swedish.find.searchFor

in the language frame.

You can place other kinds of objects in localization frames. For example, suppose
that you have an integer value that varies by language:

SetLocalizationFrame({

French: {

languageInt: 1,

},

Swedish: {

languageInt: 2,

},

German: {

languageInt: 3.

}

});

To avoid name collisions, it’s a good idea to use at least one extra naming level,
such as in the first example, which uses

find

. You can set up data objects in as

complex a hierarchy as you need within the language frame.

Using LocObj to Reference Localized Objects

20

The

LocObj

function takes two parameters:

A string or other object; this is used in the English-language version of the
application.