Package org.mycore.datamodel.language
Class MCRLanguageFactory
java.lang.Object
org.mycore.datamodel.language.MCRLanguageFactory
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the default language, as configured by "MCR.Metadata.DefaultLang"getLanguage
(String code) Returns the language with the given ISO 639-1 or -2 code.static MCRLanguageFactory
instance()
Returns the MCRLanguageFactory singletonfinal 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.
-
Field Details
-
GERMAN
-
ENGLISH
-
-
Method Details
-
instance
Returns the MCRLanguageFactory singleton -
getDefaultLanguage
Returns the default language, as configured by "MCR.Metadata.DefaultLang" -
getLanguage
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
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;
-