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:
Apache SIS developers can add resources by editing the 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).*.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
AllIndexedResourceBundle
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
andInternationalString
instances are localized using the currentResourceBundle
locale.- Long
CharSequence
instances are shortened. Class
andThrowable
instances are summarized.
- Since:
- 0.3
- Version:
- 1.3
- See Also:
-
ClassDescriptionLocale-dependent resources for error messages.The international string to be returned by
Errors.formatInternational(short)
.Resource keys.ResourceBundle
implementation accepting integers instead of strings for resource keys.The keys as an enumeration.Reads a given list of.properties
files and copies their content to.utf
files using UTF-8 encoding.Base class ofKeys
inner classes declaring key constants.Controls the resource bundle loading.Locale-dependent resources for miscellaneous (often logging) messages.The international string to be returned byMessages.formatInternational(short)
.Resource keys.Thrown when theResourceCompilerMojo
exit abnormally.Compiles the international resources that are found in the module from which this mojo is invoked.A copy ofResourceInternationalString
specialized forIndexedResourceBundle
.Locale-dependent resources for single words or short sentences.The international string to be returned byVocabulary.formatInternational(short)
.Resource keys.