org.dspace.core
Class I18nUtil

java.lang.Object
  extended by org.dspace.core.I18nUtil

public class I18nUtil
extends Object

I18nUtil.java Some Utilities for i18n Support. - getting the default Locale for this DSpace Instance - getting all supported Locales for this DSpace Instance - getting email template, help file, input forms for a given Locale

Version:
1.0
Author:
Bernadette Schlonsok and Claudia Juergen

Field Summary
static Locale DEFAULTLOCALE
           
 
Constructor Summary
I18nUtil()
           
 
Method Summary
static String getDefaultLicense(Context context)
          Get the appropriate localized version of the default.license according to language settings
static Locale getDefaultLocale()
          Gets the default locale as defined in dspace.cfg If no default locale is defined, the Locale of the JVM is used
static String getEmailFilename(Locale locale, String name)
          Get the appropriate localized version of an email template according to language settings
static Locale getEPersonLocale(EPerson ep)
          Get the Locale for a specified EPerson.
static String getInputFormsFileName(Locale locale)
          Get the appropriate localized version of input-forms.xml according to language settings
static String getMessage(String key)
          et the i18n message string for a given key and use the default Locale
static String getMessage(String key, Context c)
          Get the i18n message string for a given key and locale
static String getMessage(String key, Locale locale)
          Get the i18n message string for a given key and locale
static Locale getSupportedLocale(Locale locale)
          Gets the appropriate supported Locale according for a given Locale If no appropriate supported locale is found, the DEFAULTLOCALE is used
static Locale[] getSupportedLocales()
          get the available Locales for the User Interface as defined in dspace.cfg returns an array of Locales or null
static Locale[] parseLocales(String ll)
          Creates array of Locales from text list of locale-specifications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULTLOCALE

public static final Locale DEFAULTLOCALE
Constructor Detail

I18nUtil

public I18nUtil()
Method Detail

getDefaultLocale

public static Locale getDefaultLocale()
Gets the default locale as defined in dspace.cfg If no default locale is defined, the Locale of the JVM is used

Returns:
defaultLocale the default Locale for this DSpace instance

getEPersonLocale

public static Locale getEPersonLocale(EPerson ep)
Get the Locale for a specified EPerson. If the language is missing, return the default Locale for the repository.

Parameters:
ep -
Returns:

getSupportedLocales

public static Locale[] getSupportedLocales()
get the available Locales for the User Interface as defined in dspace.cfg returns an array of Locales or null

Returns:
an array of supported Locales or null

getSupportedLocale

public static Locale getSupportedLocale(Locale locale)
Gets the appropriate supported Locale according for a given Locale If no appropriate supported locale is found, the DEFAULTLOCALE is used

Parameters:
locale - Locale to find the corresponding Locale
Returns:
supportedLocale Locale for session according to locales supported by this DSpace instance as set in dspace.cfg

getInputFormsFileName

public static String getInputFormsFileName(Locale locale)
Get the appropriate localized version of input-forms.xml according to language settings

Parameters:
locale - Locale, the local to get the input-forms.xml for
Returns:
String - localized filename for input-forms.xml

getMessage

public static String getMessage(String key)
                         throws MissingResourceException
et the i18n message string for a given key and use the default Locale

Parameters:
key - String - name of the key to get the message for
Returns:
message String of the message
Throws:
MissingResourceException

getMessage

public static String getMessage(String key,
                                Locale locale)
                         throws MissingResourceException
Get the i18n message string for a given key and locale

Parameters:
key - String - name of the key to get the message for
locale - Locale, to get the message for
Returns:
message String of the message
Throws:
MissingResourceException

getMessage

public static String getMessage(String key,
                                Context c)
                         throws MissingResourceException
Get the i18n message string for a given key and locale

Parameters:
key - String - name of the key to get the message for
locale - Locale, to get the message for
Returns:
message String of the message
Throws:
MissingResourceException

getDefaultLicense

public static String getDefaultLicense(Context context)
Get the appropriate localized version of the default.license according to language settings

Parameters:
context - the current DSpace context
Returns:
fileName String - localized filename for default.license

getEmailFilename

public static String getEmailFilename(Locale locale,
                                      String name)
Get the appropriate localized version of an email template according to language settings

Parameters:
locale - Locale for this request
name - String - base name of the email template
Returns:
templateName String - localized filename of an email template

parseLocales

public static Locale[] parseLocales(String ll)
Creates array of Locales from text list of locale-specifications. Used to parse lists in DSpace configuration properties.

Parameters:
ll - locale list of comma-separated values
Returns:
array of locale results, possibly empty


Copyright © 2010 DuraSpace. All Rights Reserved.