Class LocaleUtilInternal


  • public final class LocaleUtilInternal
    extends java.lang.Object
    Locale utility methods.
    Since:
    8.1.0
    Version:
    $Revision: 20891 $ $Date: 2018-01-15 14:33:52 -0200 (Mon, 15 Jan 2018) $
    • Field Detail

      • LOCALE_COOKIE_NAME

        public static final java.lang.String LOCALE_COOKIE_NAME
        Locale cookie name.
        Since:
        8.1.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • LocaleUtilInternal

        public LocaleUtilInternal()
    • Method Detail

      • selectLocale

        public static java.util.Locale selectLocale​(HttpServletRequest request,
                                                    ChannelConfig channel)
                                             throws PortalException
        Returns the selected locale for a given channel and request.
        Parameters:
        request - the request.
        channel - the channel.
        Returns:
        the selected locale for a given channel and request.
        Throws:
        PortalException
        Since:
        8.1.0
      • setCookie

        public static void setCookie​(java.util.Locale locale,
                                     HttpServletRequest request,
                                     HttpServletResponse response)
        Sets the locale cookie using the given locale as value.
        Parameters:
        locale - the locale.
        request - the request.
        response - the response.
        Since:
        8.1.0
      • shouldUpdateSessionLocale

        public static boolean shouldUpdateSessionLocale​(HttpServletRequest request)
        Returns whether the session locale should be updated.
        Parameters:
        request - the request.
        Returns:
        whether the session locale should be updated.
        Since:
        8.1.0
      • markSessionLocaleToBeUpdated

        public static void markSessionLocaleToBeUpdated​(HttpServletRequest request)
        Marks the session to have the locale updated.
        Parameters:
        request - the request.
        Since:
        8.1.0
      • markSessionLocaleUpdated

        public static void markSessionLocaleUpdated​(HttpServletRequest request)
        Mark the session as having the locale updated.
        Parameters:
        request - the request.
        Since:
        8.1.0
      • isCurrentLocaleValid

        public static boolean isCurrentLocaleValid​(ChannelConfig channel)
                                            throws PortalException
        Returns whether the session locale is valid for a given channel.
        Parameters:
        channel - the channel.
        Returns:
        whether the session locale is valid for a given channel.
        Throws:
        PortalException
        Since:
        8.1.0
      • extractJsonObject

        public static org.json.simple.JSONObject extractJsonObject​(LocaleConfig locale)
        Transform Locale to JsonObject Example: { "label" : "português (Brasil)", "value" : "pt_BR" }
        Parameters:
        locale -
        Returns:
        Since:
        8.1.0