BEA Server Server User Manual


 
D TextFormatter Class Reference for BEA WebLogic Server
D-6 Internationalization Guide
*/
HelloWorldTextFormatter fmt = new HelloWorldTextFormatter(lcl);
fmt.setExtendedFormat(true);
/*
* print the text in the current locale
*/
System.out.println(fmt.helloWorld());
/*
* Alternatively, text can be accessed and formatted manually.
In this
* case you must obtain the Localizer class for the catalog.
The Localizer
* class is formed from the l10n_package attribute in the
catalog, the
* catalog name, and the string "TextLocalizer".
*/
Localizer l10n = L10nLookup.getLocalizer
(lcl,"examples.i18n.simple.HelloWorldTextLocalizer");
System.out.println(l10n.get("HELLO_AGAIN"));
/*
* If the message accepts arguments, then they can just be passed
to the
* method defined for the message.
*/
System.out.println(fmt.nthHello(3));
/*
* If using the manual method then you must manually apply the
argument to
* the text using the MessageFormat class.
*/
String text = l10n.get("NTH_HELLO");
Object[] args = {new Integer(4)};
System.out.println(MessageFormat.format(text,args));
/*
* The Localizer class also provides methods for accessing
catalog information.
*/
System.out.println(fmt.version(l10n.getVersion()));
System.out.println(fmt.l10nPackage(l10n.getL10nPackage()));
System.out.println(fmt.i18nPackage(l10n.getI18nPackage()));
System.out.println(fmt.subSystem(l10n.getSubSystem()));
}
}
Listing 4-5 shows an example of the generated TextFormatter for the HelloWorld
catalog.