Package de.uplanet.lucy.server.locale
Class GroovyLocaleUtil
java.lang.Object
de.uplanet.lucy.server.locale.GroovyLocaleUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
normalizeLocaleID
(String p_strLocaleId, boolean p_bThrowExceptionIfUnknown) Normalize the given the locale ID (language tag).parseLanguageRange
(String p_strRanges) Parse the given ranges (e.g. the value of an HTTP Accept-Language header).parseLanguageRangeForLocales
(String p_strRanges, Collection<String> p_allowedLocaleIds) Parse the given ranges (e.g. the value of an HTTP Accept-Language header) for languages that are in the given collection.parseLanguageRangeForPortal
(String p_strRanges) Parse the given ranges (e.g. the value of an HTTP Accept-Language header) for languages that are defined as portal languages.
-
Method Details
-
normalizeLocaleID
Normalize the given the locale ID (language tag).- Parameters:
p_strLocaleId
- A locale ID.p_bThrowExceptionIfUnknown
-true
if an exception should be thrown if the given local ID is unknown, orfalse
otherwise.- Returns:
- The normalized locale ID, or the given value, if
p_bThrowExceptionIfUnknown
isfalse
. - Throws:
de.uplanet.util.UnknownLocaleIdException
- Ifp_bThrowExceptionIfUnknown
istrue
and the given language ID is unknown.IllegalArgumentException
- If the given locale ID isnull
or empty.
-
parseLanguageRange
Parse the given ranges (e.g. the value of an HTTP Accept-Language header).- Parameters:
p_strRanges
- The language range.
-
parseLanguageRangeForLocales
public static List<String> parseLanguageRangeForLocales(String p_strRanges, Collection<String> p_allowedLocaleIds) Parse the given ranges (e.g. the value of an HTTP Accept-Language header) for languages that are in the given collection.If the range contains a country specific locale ID but not the corresponding country neutral locale ID, the country neutral ID will be in the result if it is contained in the given collection.
- Parameters:
p_strRanges
- The language range.p_allowedLocaleIds
- A collection of allowed locale IDs (language tags).
-
parseLanguageRangeForPortal
Parse the given ranges (e.g. the value of an HTTP Accept-Language header) for languages that are defined as portal languages.- Parameters:
p_strRanges
- The language range.
-