Package org.apache.sis.util.resources


package org.apache.sis.util.resources
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:

  • the key name ends with the '_' character followed by the expected number of parameters;
  • the value string is compliant with the MessageFormat syntax.
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 latter advantage is important for messages in which 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: For convenience, all IndexedResourceBundle subclasses provide also various format(int, …) static methods for fetching localized texts in the system default locale: If the locale is not known at method invocation time, formatInternational(int, …) static methods returns a localizable string which can be localized later: If optional arguments are present, then the following types are handled in a special way (non exhaustive list):
  • Number, Date, CodeList and InternationalString instances are localized using the current ResourceBundle locale.
  • Long CharSequence instances are shortened.
  • Class and Throwable instances are summarized.
Since:
0.3
Version:
1.3
See Also: