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
  • Method Details

    • 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
    • getSupportedLocale

      public static Locale getSupportedLocale(String locale)
      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

      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 for
      locale - 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 for
      c - 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 request
      name - String - base name of the email template
      Returns:
      templateName String - localized filename of an email template
    • getLDNFilename

      public static String getLDNFilename(Locale locale, String name)
      Get the appropriate localized version of a ldn template according to language settings
      Parameters:
      locale - Locale for this request
      name - String - base name of the ldn template
      Returns:
      templateName String - localized filename of a ldn template
    • parseLocales

      public static Locale[] parseLocales(String[] locales)
      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

      public static boolean isSupportedLocale(Locale locale)
      Check if the input locale is in the list of supported locales
      Parameters:
      locale -
      Returns:
      true if locale is supported, false otherwise