Package org.dspace.core
Class I18nUtil
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description static LocaleDEFAULTLOCALE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetDefaultLicense(Context context)Get the appropriate localized version of the default.license according to language settingsstatic LocalegetDefaultLocale()Gets the default locale as defined in dspace.cfg If no default locale is defined, the Locale of the JVM is usedstatic StringgetEmailFilename(Locale locale, String name)Get the appropriate localized version of an email template according to language settingsstatic LocalegetEPersonLocale(EPerson ep)Get the Locale for a specified EPerson.static StringgetInputFormsFileName(Locale locale)Get the appropriate localized version of submission-forms.xml according to language settingsstatic StringgetMessage(String key)Get the i18n message string for a given key and use the default Locale.static StringgetMessage(String key, Locale locale)Get the i18n message string for a given key and localestatic StringgetMessage(String key, Context c)Get the i18n message string for a given key and contextstatic LocalegetSupportedLocale(Locale locale)Gets the appropriate supported Locale according for a given Locale If no appropriate supported locale is found, the DEFAULTLOCALE is usedstatic Locale[]getSupportedLocales()get the available Locales for the User Interface as defined in dspace.cfg returns an array of Locales or nullstatic Locale[]parseLocales(String[] locales)Creates array of Locales from text list of locale-specifications.
-
-
-
Field Detail
-
DEFAULTLOCALE
public static final Locale DEFAULTLOCALE
-
-
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- Eperson- Returns:
- Locale
-
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 submission-forms.xml according to language settings- Parameters:
locale- Locale, the local to get the submission-forms.xml for- Returns:
- String - localized filename for submission-forms.xml
-
getMessage
public static String getMessage(String key)
Get 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
-
getMessage
public static String getMessage(String key, Locale locale)
Get the i18n message string for a given key and locale- Parameters:
key- String - name of the key to get the message forlocale- Locale, to get the message for- Returns:
- message String of the message
-
getMessage
public static String getMessage(String key, Context c)
Get the i18n message string for a given key and context- Parameters:
key- String - name of the key to get the message forc- Context having the desired Locale- Returns:
- message String of the message
-
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 requestname- String - base name of the email template- Returns:
- templateName String - localized filename of an email template
-
-