Package de.uplanet.lucy.server.locale
Class GroovyLocaleUtil
- java.lang.Object
-
- de.uplanet.lucy.server.locale.GroovyLocaleUtil
-
@Scriptable public final class GroovyLocaleUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
normalizeLocaleID(String p_strLocaleId, boolean p_bThrowExceptionIfUnknown)
Normalize the given the locale ID (language tag).static List<String>
parseLanguageRange(String p_strRanges)
Parse the given ranges (e.g.static List<String>
parseLanguageRangeForLocales(String p_strRanges, Collection<String> p_allowedLocaleIds)
Parse the given ranges (e.g.static List<String>
parseLanguageRangeForPortal(String p_strRanges)
Parse the given ranges (e.g.
-
-
-
Method Detail
-
normalizeLocaleID
public static String normalizeLocaleID(String p_strLocaleId, boolean p_bThrowExceptionIfUnknown)
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
public static List<String> parseLanguageRange(String p_strRanges)
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).
-
-