wicket
Class Localizer

java.lang.Object
  extended by wicket.Localizer

public class Localizer
extends java.lang.Object

A utility class that encapsulates all of the localization related functionality in a way that it can be accessed by all areas of the framework in a consistent way. A singleton instance of this class is available via the Application object.

You may register additional IStringResourceLoader to extend or replace Wickets default search strategy for the properties. E.g. string resource loaders which load the properties from a database. There should be no need to extend Localizer.

Author:
Chris Turner, Juergen Donnerstag
See Also:
Settings.getLocalizer(), IStringResourceLoader, Settings.getStringResourceLoaders()

Constructor Summary
Localizer(Application application)
          Create the utils instance class backed by the configuration information contained within the supplied application object.
 
Method Summary
 java.lang.String getString(java.lang.String key, Component component)
           
 java.lang.String getString(java.lang.String key, Component component, IModel model)
           
 java.lang.String getString(java.lang.String key, Component component, IModel model, java.util.Locale locale, java.lang.String style, java.lang.String defaultValue)
          Get the localized string using all of the supplied parameters.
 java.lang.String getString(java.lang.String key, Component component, IModel model, java.lang.String defaultValue)
           
 java.lang.String getString(java.lang.String key, Component component, java.lang.String defaultValue)
           
 java.lang.String getString(java.lang.String key, java.lang.String path, java.util.List searchStack, java.util.Locale locale, java.lang.String style)
          Note: This implementation does NOT perform variable substitution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Localizer

public Localizer(Application application)
Create the utils instance class backed by the configuration information contained within the supplied application object.

Parameters:
application - The application to localize for
Method Detail

getString

public java.lang.String getString(java.lang.String key,
                                  Component component)
                           throws java.util.MissingResourceException
Parameters:
key - The key to obtain the resource for
component - The component to get the resource for
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown
See Also:
getString(String, Component, IModel, Locale, String, String)

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  IModel model)
                           throws java.util.MissingResourceException
Parameters:
key - The key to obtain the resource for
component - The component to get the resource for
model - The model to use for property substitutions in the strings (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown
See Also:
getString(String, Component, IModel, Locale, String, String)

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  IModel model,
                                  java.lang.String defaultValue)
                           throws java.util.MissingResourceException
Parameters:
key - The key to obtain the resource for
component - The component to get the resource for
model - The model to use for property substitutions in the strings (optional)
defaultValue - The default value (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown
See Also:
getString(String, Component, IModel, Locale, String, String)

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  java.lang.String defaultValue)
                           throws java.util.MissingResourceException
Parameters:
key - The key to obtain the resource for
component - The component to get the resource for
defaultValue - The default value (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown
See Also:
getString(String, Component, IModel, Locale, String, String)

getString

public java.lang.String getString(java.lang.String key,
                                  Component component,
                                  IModel model,
                                  java.util.Locale locale,
                                  java.lang.String style,
                                  java.lang.String defaultValue)
                           throws java.util.MissingResourceException
Get the localized string using all of the supplied parameters. This method is left public to allow developers full control over string resource loading. However, it is recommended that one of the other convenience methods in the class are used as they handle all of the work related to obtaining the current user locale and style information.

Parameters:
key - The key to obtain the resource for
component - The component to get the resource for (optional)
model - The model to use for substitutions in the strings (optional)
locale - The locale to get the resource for (optional)
style - The style to get the resource for (optional) (see Session)
defaultValue - The default value (optional)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String path,
                                  java.util.List searchStack,
                                  java.util.Locale locale,
                                  java.lang.String style)
                           throws java.util.MissingResourceException
Note: This implementation does NOT perform variable substitution

Parameters:
key - The key to obtain the resource for
searchStack - A stack of classes to get the resource for
path - The component id path relative to the page
locale - The locale to get the resource for (optional)
style - The style to get the resource for (optional) (see Session)
Returns:
The string resource
Throws:
java.util.MissingResourceException - If resource not found and configuration dictates that exception should be thrown


Copyright © 2004-2007 Wicket developers. All Rights Reserved.