| org.tigris.scarab.tools.ScarabLocalizationTool
All known Subclasses: org.tigris.scarab.test.mocks.MockScarabLocalizationTool,
ScarabLocalizationTool | public class ScarabLocalizationTool extends LocalizationTool (Code) | | Scarab-specific localiztion tool. Uses a specific property
format to map a generic i10n key to a specific screen.
For example, the $i10n.title on the screen:
admin/AddPermission.vm would be in ScarabBundle_en.properties
admin/AddPermission.vm.Title
author: Daniel Rall author: Eric Pugh |
Field Summary | |
public static Locale | DEFAULT_LOCALE The Locale to be used, if the Resource could not be found in
one of the Locales specified in the Browser's language preferences. |
Method Summary | |
protected String | findProperty(String property) Retrieves the localized version of the value of property .
Parameters: property - The name of the property whose value to retrieve. | public String | format(String key, Object arg1) Formats a localized value using the provided object.
Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. | public String | format(String key, Object arg1, Object arg2) Formats a localized value using the provided objects.
Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Parameters: arg2 - The object to use as {1} when formatting the localized text. | public String | format(String key, Object arg1, Object arg2, Object arg3) Formats a localized value using the provided objects.
Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Parameters: arg2 - The object to use as {1} when formatting the localized text. Parameters: arg3 - The object to use as {2} when formatting the localized text. | public String | format(String key, List args) Formats a localized value using the provided objects.
ResourceBundle:
VelocityUsersNotWrong={0} out of {1} users can't be wrong!
Template:
$l10n.format("VelocityUsersNotWrong", ["9", "10"])
Result:
9 out of 10 Velocity users can't be wrong!
Parameters: key - The identifier for the localized text to retrieve, Parameters: args - The objects to use as {0}, {1}, etc. | public String | format(String key, Object[] args) Formats a localized value using the provided objects.
Take into account the Browser settings (in order of preference),
the Turbine default settings and the System Locale,
if the Turbine Default Locale is not defined.
Parameters: key - The identifier for the localized text to retrieve, Parameters: args - The MessageFormat data used when formattingthe localized text. | public String | get(Localizable key) Return the localized property value. | public String | get(String key) Return the localized property value. | protected String | getBundleName() | public String | getIgnoreMissingResource(String key) Return the localized property value. | public String | getMessage(Throwable t) Extract a message from an exception. | public Locale | getPrimaryLocale() Gets the primary locale. | public String | getTitle() Provides $l10n.Title to templates, grabbing it
from the title property for the current template. | public void | init(Object obj) Initialize the tool. | public boolean | isFilterEnabled() Whether our cross-site scripting filter is enabled. | public void | refresh() Reset this instance to initial values. | public void | restoreBundlePrefix() Restore the old Bundle Prefix to it's previous value. | public void | setBundlePrefix(String prefix) Change the BundlePrefix. | public void | setFilterEnabled(boolean v) Allow us to be able to enable/disable our cross-site scripting filter
when rendering something from the format() method. |
DEFAULT_LOCALE | public static Locale DEFAULT_LOCALE(Code) | | The Locale to be used, if the Resource could not be found in
one of the Locales specified in the Browser's language preferences.
|
findProperty | protected String findProperty(String property)(Code) | | Retrieves the localized version of the value of property .
Parameters: property - The name of the property whose value to retrieve. The localized property value. |
format | public String format(String key, Object arg1)(Code) | | Formats a localized value using the provided object.
Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Formatted localized text. See Also: ScarabLocalizationTool.format(String,List) |
format | public String format(String key, Object arg1, Object arg2)(Code) | | Formats a localized value using the provided objects.
Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Parameters: arg2 - The object to use as {1} when formatting the localized text. Formatted localized text. See Also: ScarabLocalizationTool.format(String,List) |
format | public String format(String key, Object arg1, Object arg2, Object arg3)(Code) | | Formats a localized value using the provided objects.
Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Parameters: arg2 - The object to use as {1} when formatting the localized text. Parameters: arg3 - The object to use as {2} when formatting the localized text. Formatted localized text. See Also: ScarabLocalizationTool.format(String,List) |
format | public String format(String key, List args)(Code) | | Formats a localized value using the provided objects.
ResourceBundle:
VelocityUsersNotWrong={0} out of {1} users can't be wrong!
Template:
$l10n.format("VelocityUsersNotWrong", ["9", "10"])
Result:
9 out of 10 Velocity users can't be wrong!
Parameters: key - The identifier for the localized text to retrieve, Parameters: args - The objects to use as {0}, {1}, etc. when formatting thelocalized text. Formatted localized text. |
format | public String format(String key, Object[] args)(Code) | | Formats a localized value using the provided objects.
Take into account the Browser settings (in order of preference),
the Turbine default settings and the System Locale,
if the Turbine Default Locale is not defined.
Parameters: key - The identifier for the localized text to retrieve, Parameters: args - The MessageFormat data used when formattingthe localized text. Formatted localized text. See Also: ScarabLocalizationTool.format(String,List) |
get | public String get(Localizable key)(Code) | | Return the localized property value.
Take into account the Browser settings (in order of preference),
the Turbine default settings and the System Locale,
if the Turbine Default Locale is not defined.
|
get | public String get(String key)(Code) | | Return the localized property value.
Take into account the Browser settings (in order of preference),
the Turbine default settings and the System Locale,
if the Turbine Default Locale is not defined.
NOTE: Please don't use this method from the Java-code.
It is intended for use with Velocity only!
ScarabLocalizationTool.get(LocalizationKey) |
getBundleName | protected String getBundleName()(Code) | | Get the default ResourceBundle name
|
getIgnoreMissingResource | public String getIgnoreMissingResource(String key)(Code) | | Return the localized property value.
Take into account the Browser settings (in order of preference),
the Turbine default settings and the System Locale,
if the Turbine Default Locale is not defined.
NOTE: Please don't use this method from the Java-code.
It is intended for use with Velocity only!
ScarabLocalizationTool.get(LocalizationKey) |
getMessage | public String getMessage(Throwable t)(Code) | | Extract a message from an exception. This method checks, if
the exception is Localizable. If so, we now can retrieve the localized exception message.
Otherwise we retrieve the standard message via e.getLocalizedMessage().
Parameters: e - throws NullPointerException if t is null |
getPrimaryLocale | public Locale getPrimaryLocale()(Code) | | Gets the primary locale.
The primary locale is the locale which will be choosen
at first from the set of Locales which are accepted by the user
as defined on the Browser language preferrences.
The primary locale currently in use. |
getTitle | public String getTitle()(Code) | | Provides $l10n.Title to templates, grabbing it
from the title property for the current template.
The title for the template used in the current request, ornull if title property was not found inthe available resource bundles. |
init | public void init(Object obj)(Code) | | Initialize the tool. Within the turbine pull service this tool is
initialized with a RunData. However, the tool can also be initialized
with a Locale.
|
isFilterEnabled | public boolean isFilterEnabled()(Code) | | Whether our cross-site scripting filter is enabled.
|
refresh | public void refresh()(Code) | | Reset this instance to initial values.
Probably needed for reuse of ScarabLocalizationTool Instances.
|
restoreBundlePrefix | public void restoreBundlePrefix()(Code) | | Restore the old Bundle Prefix to it's previous value.
|
setBundlePrefix | public void setBundlePrefix(String prefix)(Code) | | Change the BundlePrefix. Keep the original value for later
restore
Parameters: prefix - |
setFilterEnabled | public void setFilterEnabled(boolean v)(Code) | | Allow us to be able to enable/disable our cross-site scripting filter
when rendering something from the format() method. The default is to
have it enabled.
|
|
|