Class MCRTranslation

java.lang.Object
org.mycore.services.i18n.MCRTranslation

public class MCRTranslation extends Object
provides services for internationalization in mycore application. You have to provide a property file named messages.properties in your classpath for this class to work.
Author:
Radi Radichev, Thomas Scheffler (yagee)
  • Constructor Details

    • MCRTranslation

      public MCRTranslation()
  • Method Details

    • translate

      public static String translate(String label)
      provides translation for the given label (property key). The current locale that is needed for translation is gathered by the language of the current MCRSession.
      Parameters:
      label - property key
      Returns:
      translated String
    • exists

      public static boolean exists(String label)
      Checks whether there is a value for the given label and current locale.
      Parameters:
      label - property key
      Returns:
      true if there is a value, false otherwise
    • translateWithBaseName

      public static String translateWithBaseName(String label, String baseName)
      provides translation for the given label (property key). The current locale that is needed for translation is gathered by the language of the current MCRSession.
      Parameters:
      label - property key
      baseName - a fully qualified class name
      Returns:
      translated String
    • translate

      public static String translate(String label, Locale locale)
      provides translation for the given label (property key).
      Parameters:
      label - property key
      locale - target locale of translation
      Returns:
      translated String
    • translate

      public static String translate(String label, Locale locale, String baseName)
      provides translation for the given label (property key).
      Parameters:
      label - property key
      locale - target locale of translation
      baseName - a fully qualified class name
      Returns:
      translated String
    • translatePrefix

      public static Map<String,String> translatePrefix(String prefix)
      Returns a map of label/value pairs which match with the given prefix. The current locale that is needed for translation is gathered by the language of the current MCRSession.
      Parameters:
      prefix - label starts with
      Returns:
      map of labels with translated values
    • translatePrefix

      public static Map<String,String> translatePrefix(String prefix, Locale locale)
      Returns a map of label/value pairs which match with the given prefix.
      Parameters:
      prefix - label starts with
      locale - target locale of translation
      Returns:
      map of labels with translated values
    • translate

      public static String translate(String label, Object... arguments)
      provides translation for the given label (property key). The current locale that is needed for translation is gathered by the language of the current MCRSession.
      Parameters:
      label - property key
      arguments - Objects that are inserted instead of placeholders in the property values
      Returns:
      translated String
    • translate

      public static String translate(String label, String argument)
      provides translation for the given label (property key). The current locale that is needed for translation is gathered by the language of the current MCRSession. Be aware that any occurence of ';' and '\' in argument has to be masked by '\'. You can use ';' to build an array of arguments: "foo;bar" would result in {"foo","bar"} (the array)
      Parameters:
      label - property key
      argument - String that is inserted instead of placeholders in the property values
      Returns:
      translated String
      See Also:
    • getCurrentLocale

      public static Locale getCurrentLocale()
    • getLocale

      public static Locale getLocale(String language)
    • getAvailableLanguages

      public static Set<String> getAvailableLanguages()
    • getAvailableLanguagesAsXML

      public static Document getAvailableLanguagesAsXML()
    • getResourceBundle

      public static ResourceBundle getResourceBundle(String baseName, Locale locale)