Browse Prior Art Database

Alphanumeric Parameter Substitution in NLS Messages

IP.com Disclosure Number: IPCOM000020460D
Original Publication Date: 2003-Nov-21
Included in the Prior Art Database: 2003-Nov-21
Document File: 3 page(s) / 59K

Publishing Venue

IBM

Abstract

Programmers traditionally use numeric message parameters when writing Java of XPG/4 based programs. This paper describes a better method of using alphanumeric / mnemonic parameters that reduce the chance of coding or translation errors when developing code for the global market.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 55% of the total text.

Page 1 of 3

Alphanumeric Parameter Substitution in NLS Messages

Using Alphanumeric Parameter Substitution in NLS Messaging

In the Java* and XPG/4** worlds, NLS messages are usually placed in .PROPERTIES files or message catalogs using numeric parameters that are formatted and substituted into message text at runtime. As an example, the error message below would appear in a .PROPERTIES file as:

XYZ1234=XYZ1234E: Failure to connect to {0} using {1} via {2}.

The NLS translator is free to rewrite the error to follow the conventions of the locale. This may include changing the sense of the message from an active voice to a passive one or vice-versa.

XYZ1234=XYZ1234E: Xxxx {2} yyyyy zzz {0} aaaa bbbbb {1}.

The NLS translator needs comments to understand the meaning of what {0}, {1}, {2} really mean. The programmer must provide comments to define each numeric identifier.

The new idea is to allow self documenting alphanumeric / mnemonic parameters so that the NLS message becomes:

    XYZ1234E: Failure to connect to {TargetDB} using {LoginUser} via {NetProtocol}

Programmatically, the message formatting method would use a PROPERTIES object to store the values of parameters rather than a reuseable STRING array per message that contains the values of the numeric parameters in the proper order for that specific message as is done in the current Java* and XPG/4** environments. Parameter indexing is more susceptible to error. The mnemonic parameter strategy is self documenting for both the programmer and the NLS translator and is thus less error prone.

The code below shows a sample msgFormatting method scanning for {...} tags and replacing them with a value from a Java Proper...