Class MCRLanguageFactory

java.lang.Object
org.mycore.datamodel.language.MCRLanguageFactory

public class MCRLanguageFactory extends Object
Returns MCRLanguage instances. The languages most commonly used, English and German, are provided as constants. Other languages are read from a classification thats ID can be configured using the property "MCR.LanguageClassification". That classification should use ISO 639-1 code as category ID, where ISO 639-2 codes can be added by extra labels x-term and x-bibl for the category. Unknown languages are created by code as required, but a warning is logged.
Author:
Frank Lützenkirchen
  • Field Details

  • Method Details

    • instance

      public static MCRLanguageFactory instance()
      Returns the MCRLanguageFactory singleton
    • getDefaultLanguage

      public MCRLanguage getDefaultLanguage()
      Returns the default language, as configured by "MCR.Metadata.DefaultLang"
    • getLanguage

      public MCRLanguage getLanguage(String code)
      Returns the language with the given ISO 639-1 or -2 code. When the given code contains a subcode like "en-us", and the main language is configured, that main language is returned. When the given code does not match any language configured, a language is created on-the-fly, but a warning is logged.
    • isSupportedLanguage

      public final boolean isSupportedLanguage(String code)
      This method check the language string base on RFC 1766 to the supported languages in MyCoRe in a current application environment. Without appending this MCRLanguageFactory only ENGLISH and GERMAN are supported.
      Parameters:
      code - the language string in RFC 1766 syntax
      Returns:
      true if the language code is supported. It return true too if the code starts with x- or i-, otherwise return false;