net.jetrix
Class Language

java.lang.Object
  extended by net.jetrix.Language

public class Language
extends Object

Helper class to handle and retrieve localized strings.

Version:
$Revision: 545 $, $Date: 2005-01-05 18:16:04 +0100 (mer., 05 janv. 2005) $
Author:
Emmanuel Bourg

Method Summary
static Language getInstance()
          Return the unique instance of this class.
static Collection<Locale> getLocales()
          Return the list of languages supported by the server.
 ResourceBundle getResourceBundle(Locale locale)
          Return the ResourceBundle for the specified locale.
static String getText(String key, Locale locale)
          Return the specified localized text for a given locale.
static String getText(String key, Locale locale, Object... arguments)
          Return the specified localized text for a given locale and replace the parameters with an array of arguments.
static boolean isSupported(Locale locale)
          Tell if the specified locale has a corresponding resource file available.
 ResourceBundle load(Locale locale)
          Load and return the ResourceBundle for the specified locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Language getInstance()
Return the unique instance of this class.


load

public ResourceBundle load(Locale locale)
Load and return the ResourceBundle for the specified locale. Bundles are cached in a local Map.

Parameters:
locale - the locale of the returned bundle if available

getResourceBundle

public ResourceBundle getResourceBundle(Locale locale)
Return the ResourceBundle for the specified locale.

Parameters:
locale - the locale of the bundle to return

isSupported

public static boolean isSupported(Locale locale)
Tell if the specified locale has a corresponding resource file available.

Parameters:
locale - the locale to test
Returns:
true if the locale is supported, false if not.

getLocales

public static Collection<Locale> getLocales()
Return the list of languages supported by the server.


getText

public static String getText(String key,
                             Locale locale)
Return the specified localized text for a given locale.

Parameters:
key - the text key in the resource bundle
locale - the locale of the message

getText

public static String getText(String key,
                             Locale locale,
                             Object... arguments)
Return the specified localized text for a given locale and replace the parameters with an array of arguments.

Parameters:
key - the text key in the resource bundle
locale - the locale of the message
arguments - the array of arguments
Since:
0.2


Copyright © 2001-2008 Emmanuel Bourg. All Rights Reserved.