background image
C H A P T E R 2 0
Localizing Newton Applications
Using the Localization Features of the Newton
A frames path the compiler uses to find the alternative object when the
Language setting in the Project Settings dialog box is for anything other than
English. You should avoid having reserved words in the path--refer to Appendix
A of The NewtonScript Programming Language for a complete list of reserved
words in NewtonScript.
If you display a message while searching for an object, for example, you can set up
the message for any language by wrapping the string in the
msg := LocObj("Searching for ^0...", 'find.searchfor)
When an English-language version of the application is compiled, the
function simply returns its first argument; this implementation helps keep code
readable by allowing you to use English strings in your code. For non-English
versions of the application, the
function uses the value of the
slot in NTK Package Settings and the path expression passed as its second
argument to return the appropriate object from the localization frame.
As another example, an application that is not localized might provide user feedback
by passing the string
"Not found."
to the
function, as in the
following code fragment:
:SetStatus("Not found.");
The localized version of the same code uses the
function to return a path
expression based on the
argument and the language for which the
application is compiled. The
function then uses this path expression
to reference the localized string. Because the
function returns this path
expression as its result, the argument to
can be "wrapped" in a call to
function, as in the following line of code:
:SetStatus( LocObj("Not found", 'find.nope) );
The object passed to the
method doesn't have to be a string; it can be an
array or an immediate value.
The path expression that references the object must be unique across the entire
system. Thus, to avoid name collisions, it's recommended that you use additional
naming levels based on your application symbol; for example,
introduces a third naming level to the path expression.
Use ParamStr Rather Than "&" and "&&" Concatenation
While it is often convenient to use the ampersand string concatenators
function provides a much more flexible and powerful way to
parameterize the construction of strings, which helps you customize your strings
for different languages by, for example, varying word order.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна