| A tag interface that facilitates locale-sensitive, compile-time binding of
messages supplied from properties files. Using
GWT.create(class) to "instantiate" an interface that
extends Messages returns an instance of an automatically
generated subclass that is implemented using message templates from a
property file selected based on locale. Message templates are based on a
subset of the format used by MessageFormat .
Locale is specified at run time using a meta tag or query string as described
for
com.google.gwt.i18n.client.Localizable .
Extending Messages
To use Messages , begin by defining an interface that extends
it. Each interface method is referred to as a message accessor, and
the name of each message accessor is assumed to match the name of a property
defined in a properties file. For example,
expects to find properties named turnsLeft and
currentScore in an associated properties file, formatted as
message templates taking two arguments and one argument, respectively. For
example, the following properties would correctly bind to the
GameStatusMessages interface:
The following example demonstrates how to use constant accessors defined in
the interface above:
It is possible to change the property name bound to a message accessor using
the gwt.key doc comment, exactly as is done for constant
accessors. See
Constants for an example.
Defining Message Accessors
Message accessors must be of the form
String methodName(optional-params)
and parameters may be of any type. Arguments are converted into strings at
runtime using Java string concatenation syntax (the '+' operator), which
uniformly handles primitives, null , and invoking
toString() to format objects.
Compile-time checks are performed to ensure that the number of placeholders
in a message template (e.g. {0} ) matches the number of
parameters supplied.
Binding to Properties Files
Interfaces extending Messages are bound to properties file
using the same algorithm as interfaces extending Constants .
See the documentation for
Constants for a description of the
algorithm.
Required Module
Modules that use this interface should inherit
com.google.gwt.i18n.I18N .
Note
You should not directly implement this interface or interfaces derived from
it since an implementation is generated automatically when message interfaces
are created using
com.google.gwt.core.client.GWT.create(Class) .
|