C H A P T E R 2 0
Localizing Newton Applications
Using the Localization Features of the Newton
Measuring String Widths at Compile Time
When the size of a screen element depends on the size of associated text, you can
function to determine, at compile time, how big to make
the screen element. If you want to determine the size at runtime, use
You could establish the width of the search message, for example, by using
MeasureString(LocObj("What is your name?",
At compile time, the
call is replaced with a constant as long as
the arguments to
are also constant. (
constant result at compile time.) You could access the width at run time from the
method with this function:
local newBounds := deepClone(viewBounds);
newBounds.right := newBounds.left +
MeasureString("This is a string", simpleFont12);
SetValue(self, 'viewBounds, newBounds);
Determining Language at Run Time
You can determine the language at run time, and your program can use that
information to modify its behavior.
There are two ways to determine the current language:
Examine the active locale bundle. You can also add new locale bundles to give
the user new locale options and can set the locale from within your program.
The sections that follow discuss how to examine the active locale bundle.
function to find out the native language
for which the ROMs on the Newton device are implemented.
Note that you need to decide which of these methods your application should use
in order to determine its behavior.
Examining the Active Locale Bundle
The global function
returns the active locale bundle, which is the
locale bundle that the Country pop-up is currently set to. Use this function rather
than accessing the frame directly.