| java.lang.Object org.apache.velocity.tools.view.i18n.MultiViewsTool
Constructor Summary | |
public | MultiViewsTool() Creates a new uninitialized instance. |
DEFAULT_LANGUAGE_KEY | final protected static String DEFAULT_LANGUAGE_KEY(Code) | | The key used to search initialization, context, and JVM
parameters for the default language to use.
|
defaultLanguage | protected String defaultLanguage(Code) | | The two character abbreviation for the request's default
language.
|
findLocalizedResource | public String findLocalizedResource(String name, String language)(Code) | | Finds the a localized version of the requested Velocity
resource (such as a file or template) which is most appropriate
for the locale of the current request. Use in conjuction with
Apache httpd's MultiViews , or by itself.
Usage from a template would be something like the following:
#parse ($multiviews.findLocalizedResource("header.vm", "en"))
#include ($multiviews.findLocalizedResource("my_page.html", "en"))
#parse ($multiviews.findLocalizedResource("footer.vm", "en"))
You might also wrap this method using another pull/view tool
which does internationalization/localization/content negation
for a single point of access.
Parameters: name - The unlocalized name of the file to find. Parameters: language - The language to find localized context for. The localized file name, or name if it isnot localizable. |
init | public void init(Object obj)(Code) | | Extracts the default language from the specified
ViewContext , looking first at the Velocity
context, then the servlet context, then lastly at the JVM
default. This "narrow scope to wide scope" pattern makes it
easy to setup language overrides at different levels within
your application.
Parameters: obj - the current ViewContext throws: IllegalArgumentException - if the param is not a ViewContext |
|
|