|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.turbine.services.localization.LocalizationTool
public class LocalizationTool
A pull tool which provides lookups for localized text by delegating
to the configured Fulcrum LocalizationService.
| Field Summary | |
|---|---|
protected Locale |
locale
The language and country information parsed from the request's Accept-Language header. |
| Constructor Summary | |
|---|---|
LocalizationTool()
Creates a new instance. |
|
| Method Summary | |
|---|---|
String |
format(String key,
Object arg1)
Formats a localized value using the provided object. |
String |
format(String key,
Object[] args)
Formats a localized value using the provided objects. |
String |
format(String key,
Object arg1,
Object arg2)
Formats a localized value using the provided objects. |
String |
get(String key)
Performs text lookups for localization. |
protected String |
getBundleName(Object data)
The return value of this method is used to set the name of the bundle used by this tool. |
Locale |
getLocale()
Gets the current locale. |
org.apache.fulcrum.localization.LocalizationService |
getLocalizationService()
Lazy load the LocalizationService. |
void |
init(Object data)
Sets the request to get the Accept-Language header
from (reset on each request). |
void |
refresh()
No-op. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Locale locale
Accept-Language header. Reset on each request.
| Constructor Detail |
|---|
public LocalizationTool()
PullService.
| Method Detail |
|---|
public org.apache.fulcrum.localization.LocalizationService getLocalizationService()
public String get(String key)
Performs text lookups for localization.
Assuming there is a instance of this class with a HTTP
request set in your template's context named l10n,
the VTL $l10n.HELLO would render to
hello for English requests and hola
in Spanish (depending on the value of the HTTP request's
Accept-Language header).
key - The identifier for the localized text to retrieve.
public Locale getLocale()
protected String getBundleName(Object data)
LocalizationService configuration.
data - The inputs passed from init(Object).
(ignored by this implementation).
public String format(String key,
Object arg1)
key - The identifier for the localized text to retrieve,arg1 - The object to use as {0} when formatting the localized text.
#format(String, Locale, String, Object[])
public String format(String key,
Object arg1,
Object arg2)
key - The identifier for the localized text to retrieve,arg1 - The object to use as {0} when formatting the localized text.arg2 - The object to use as {1} when formatting the localized text.
#format(String, Locale, String, Object[])
public String format(String key,
Object[] args)
key - The identifier for the localized text to retrieve,args - The objects to use as {0}, {1}, etc. when
formatting the localized text.
public void init(Object data)
Accept-Language header
from (reset on each request).
init in interface ApplicationTooldata - initialization datapublic void refresh()
refresh in interface ApplicationTool
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||