Package org.dspace.core
Class I18nUtil
java.lang.Object
org.dspace.core.I18nUtil
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDefaultLicense(Context context) Get the appropriate localized version of the default.license according to language settingsstatic LocaleGets 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 LocaleGet the Locale for a specified EPerson.static StringgetInputFormsFileName(Locale locale) Get the appropriate localized version of submission-forms.xml according to language settingsstatic StringgetLDNFilename(Locale locale, String name) Get the appropriate localized version of a ldn template 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(String locale) Gets the appropriate supported Locale according for a given Locale If no appropriate supported locale is found, the DEFAULTLOCALE is usedstatic 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[]get the available Locales for the User Interface as defined in dspace.cfg returns an array of Locales or nullstatic booleanisSupportedLocale(Locale locale) Check if the input locale is in the list of supported localesstatic Locale[]parseLocales(String[] locales) Creates array of Locales from text list of locale-specifications.
-
Method Details
-
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
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
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
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
-
getSupportedLocale
Gets the appropriate supported Locale according for a given Locale If no appropriate supported locale is found, the DEFAULTLOCALE is used- Parameters:
locale- String to find the corresponding Locale- Returns:
- supportedLocale Locale for session according to locales supported by this DSpace instance as set in dspace.cfg
-
getInputFormsFileName
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
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
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
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
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
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
-
getLDNFilename
Get the appropriate localized version of a ldn template according to language settings- Parameters:
locale- Locale for this requestname- String - base name of the ldn template- Returns:
- templateName String - localized filename of a ldn template
-
parseLocales
Creates array of Locales from text list of locale-specifications. Used to parse lists in DSpace configuration properties.- Parameters:
locales- locale string array- Returns:
- array of locale results, possibly empty
-
isSupportedLocale
Check if the input locale is in the list of supported locales- Parameters:
locale-- Returns:
- true if locale is supported, false otherwise
-