org.apache.turbine.services.localization
Class Localization

java.lang.Object
  |
  +--org.apache.turbine.services.localization.Localization

public abstract class Localization
extends java.lang.Object

Wrapper around the TurbineLocalization Service that makes it easy to grab something from the service and make the code cleaner.

Instead of typing:
((LocalizationService)TurbineServices.getInstance()
.getService(LocalizationService.SERVICE_NAME))
.getBundle(data)
.getString(str)
Now you only need to type:
Localization.getString(str)

Version:
$Id$
Author:
Jon S. Stevens

Constructor Summary
Localization()
           
 
Method Summary
static java.util.ResourceBundle getBundle(java.lang.String bundleName)
          Convenience method to get a ResourceBundle based on name.
static java.util.ResourceBundle getBundle(java.lang.String bundleName, java.util.Locale locale)
          Convenience method to get a ResourceBundle based on name and Locale.
static java.util.ResourceBundle getBundle(java.lang.String bundleName, RunData data)
          Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header in RunData.
static java.util.ResourceBundle getBundle(java.lang.String bundleName, java.lang.String languageHeader)
          Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header.
static java.lang.String getString(RunData data, java.lang.String str)
          Pulls a string out of the LocalizationService and attempts to determine the Locale by the Accept-Language header.
static java.lang.String getString(java.lang.String str)
          Pulls a string out of the LocalizationService with the default locale values of what is defined in the TurbineResources.properties file for the locale.default.language and locale.default.country property values.
static java.lang.String getString(java.lang.String str, java.lang.String lang)
          Convenience method that pulls a localized string off the LocalizationService using the default ResourceBundle name defined in the TurbineResources.properties file and the specified language name in ISO format.
static void setBundle(java.lang.String defaultBundle)
          This method sets the name of the defaultBundle.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

Localization

public Localization()
Method Detail

getString

public static java.lang.String getString(java.lang.String str)
Pulls a string out of the LocalizationService with the default locale values of what is defined in the TurbineResources.properties file for the locale.default.language and locale.default.country property values. If those cannot be found, then en/US is used.
Parameters:
str - Name of string.
Returns:
A localized String.

getString

public static java.lang.String getString(RunData data,
                                         java.lang.String str)
Pulls a string out of the LocalizationService and attempts to determine the Locale by the Accept-Language header. If that header is not present, it will fall back to using the locale values of what is defined in the TurbineResources.properties file for the locale.default.language and locale.default.country property values. If those cannot be found, then en/US is used.
Parameters:
data - Turbine information.
str - Name of string.
Returns:
A localized String.

getString

public static java.lang.String getString(java.lang.String str,
                                         java.lang.String lang)
Convenience method that pulls a localized string off the LocalizationService using the default ResourceBundle name defined in the TurbineResources.properties file and the specified language name in ISO format.
Parameters:
str - Name of string.
lang - Desired language for the localized string.
Returns:
A localized string.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String bundleName)
Convenience method to get a ResourceBundle based on name.
Parameters:
bundleName - Name of bundle.
Returns:
A localized ResourceBundle.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String bundleName,
                                                 java.lang.String languageHeader)
Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header.
Parameters:
bundleName - Name of bundle.
languageHeader - A String with the language header.
Returns:
A localized ResourceBundle.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String bundleName,
                                                 RunData data)
Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header in RunData.
Parameters:
bundleName - Name of bundle.
data - Turbine information.
Returns:
A localized ResourceBundle.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String bundleName,
                                                 java.util.Locale locale)
Convenience method to get a ResourceBundle based on name and Locale.
Parameters:
bundleName - Name of bundle.
locale - A Locale.
Returns:
A localized ResourceBundle.

setBundle

public static void setBundle(java.lang.String defaultBundle)
This method sets the name of the defaultBundle.
Parameters:
defaultBundle - Name of default bundle.


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.