org.activemath.webapp.i18n
Class Localizer

java.lang.Object
  extended by org.activemath.webapp.i18n.Localizer

public class Localizer
extends Object

Localization functions for ActiveMath's WebApp.


Method Summary
 ResourceBundle getBundle(String language)
          Get the @link ResourceBundle for language
 String getDefaultLanguage()
           
static Localizer getInstance()
           
 String getItemDifficulty(String difficulty, String lang)
          Return localized string for an Omdoc item difficulty (eg "schwer").
 String getItemTag(String omdocTag, String omdocType, String lang)
          Return localized string for an Omdoc item type (eg "Lemma", "�bung").
 Locale getLocale(String language)
           
 Set getLocales()
           
 String getPreferredLanguage(HttpServletRequest request, User user)
          Determine the preferred language for a request.
 List<String> getSupportedLanguages()
          Return a list of supported languages.
 boolean isSupportedLanguage(String language)
          Say if language is supported.
static String makeLocalizedName(String filename, String lang)
          Construct a localized (file)name.
 void resetBase()
          A means to reload the resource bundles without restarting the whole server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Localizer getInstance()

resetBase

public void resetBase()
A means to reload the resource bundles without restarting the whole server


makeLocalizedName

public static String makeLocalizedName(String filename,
                                       String lang)
Construct a localized (file)name.

Parameters:
filename - - name to localizer
lang - - language
Returns:
filename with "_lang" inserted before the suffix. ("pl/html/login.vm" --> "pl/html/login_de.vm")

getSupportedLanguages

public List<String> getSupportedLanguages()
Return a list of supported languages. List items are Strings (eg. "de", "en");


getDefaultLanguage

public String getDefaultLanguage()

isSupportedLanguage

public boolean isSupportedLanguage(String language)
Say if language is supported.

Parameters:
language - - may be null

getLocales

public Set getLocales()

getLocale

public Locale getLocale(String language)
Parameters:
language -
Returns:

getBundle

public ResourceBundle getBundle(String language)
Get the @link ResourceBundle for language

Parameters:
language -
Returns:

getPreferredLanguage

public String getPreferredLanguage(HttpServletRequest request,
                                   User user)
Determine the preferred language for a request. This takes into account:

Parameters:
request - - Request to determine language for
user - - may be null
Returns:
The first language for which @link isSupportedLanguage() is true.

getItemTag

public String getItemTag(String omdocTag,
                         String omdocType,
                         String lang)
Return localized string for an Omdoc item type (eg "Lemma", "�bung").
Tries 2 keys:

Returns:
localized string for an Omdoc item type in a language

getItemDifficulty

public String getItemDifficulty(String difficulty,
                                String lang)
Return localized string for an Omdoc item difficulty (eg "schwer").
Tries the key:

Returns:
localized string for an Omdoc item difficulty in a language