Class GroovyLocaleUtil


  • @Scriptable
    public final class GroovyLocaleUtil
    extends Object
    • 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, or false otherwise.
        Returns:
        The normalized locale ID, or the given value, if p_bThrowExceptionIfUnknown is false.
        Throws:
        de.uplanet.util.UnknownLocaleIdException - If p_bThrowExceptionIfUnknown is true and the given language ID is unknown.
        IllegalArgumentException - If the given locale ID is null 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).

        See RFC 2616; section 14.4.

        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.

        See RFC 2616; section 14.4.

        Parameters:
        p_strRanges - The language range.
        p_allowedLocaleIds - A collection of allowed locale IDs (language tags).
      • parseLanguageRangeForPortal

        public static List<String> 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.

        See RFC 2616; section 14.4.

        Parameters:
        p_strRanges - The language range.