Using tokens in message strings

Message strings can include tokens that are substituted at run-time.

For example, a search breadcrumb may need to display a spelling correction message like "No matches found for 'bearign'; showing results for 'bearing'". This message would appear in a .properties file with tokens for the two terms, as in the following example:

autocorrect-msg=No matches found for \'{0}\'; showing results for \'{1}\'

When including this message in your portlet with the LanguageUtils utility, you pass in a list of parameters to substitute for these tokens. This substitution uses the class java.text.MessageFormat. Refer to the javadoc for that class for the options available with token substitution. Tokens may also do advanced substitution, such as date substitution formatted appropriately for the locale.