Package org.apache.sis.util.resources

Localized resources for SIS.

See: Description

Package org.apache.sis.util.resources Description

Localized resources for SIS. While anyone could use the resources provided in this package, those resources are primarily for internal SIS usage and may change in any future version.

Apache SIS resources are provided in binary files having the ".utf" extension. The resource keys are numeric constants declared in the Keys static inner classes. Values are strings which may optionally have slots for one or more parameters, identified by the "{n}" characters sequences where n is the parameter number (first parameter is "{0}"). If, and only if, a string value has slots for at least one parameter, then:

Note: java.util.Formatter is an alternative to MessageFormat providing similar functionalities with a C/C++ like syntax. However MessageFormat has two advantages: it provides a choice format type (useful for handling plural forms), and localizes properly objects of unspecified type (by contrast, the Formatter "%s" type always invoke toString()). The later advantage is important for messages in wich the same argument could receive Number or Date instances as well as String. Furthermore, the java.util.logging framework is designed for use with MessageFormat (see the Formatter.formatMessage(LogRecord) method).
Apache SIS developers can add resources by editing the *.properties file in the source code directory, then run the localized resources compiler provided in the sis-build-helper module. Developers shall not apply the MessageFormat rules for using quotes, since the resources compiler will apply itself the doubled single quotes when necessary. This avoid the unfortunate confusion documented in the warning section of MessageFormat javadoc.
Usage
All IndexedResourceBundle subclasses provide a getResources(Locale) static method. It can be used for fetching localized strings as below:
String text = TheBundle.getResources(locale).getString(key, optionalArguments);
For convenience, all IndexedResourceBundle subclasses provide also various format(int, …) and formatInternational(int, …) static methods for fetching localized texts in the system default locale, or localizable texts:
InternationalString i18n = TheBundle.formatInternational(key, optionalArguments);
String text = i18n.toString(locale); // Equivalent to the above example.

text = TheBundle.format(key, optionalArguments); // Uses the default locale.
Since:
0.3 (derived from geotk-1.2)
See Also:
ResourceBundle, MessageFormat, ResourceInternationalString

Defined in the sis-utility module

Copyright © 2010–2013 The Apache Software Foundation. All rights reserved.