code: public static Locale getLocale(final HttpServletRequest request) {
          Locale locale = null;
  
          // Gets from session
          final HttpSession session = request.getSession(false);
  
          if (session != null) {
              locale = (Locale) session.getAttribute(Keys.LOCALE);
          }
  
          if (null == locale) {
              // Gets from request header
              final String languageHeader = request.getHeader("Accept-Language");
  
              LOGGER.log(Level.DEBUG, "[Accept-Language={0}]", languageHeader);
  
              String language = "zh";
              String country = "CN";
  
              if (StringUtils.isNotBlank(languageHeader)) {
                  language = getLanguage(languageHeader);
                  country = getCountry(languageHeader);
              }
  
              locale = new Locale(language, country);
  
              if (!hasLocale(locale)) {
                  // Uses default
                  locale = Latkes.getLocale();
                  LOGGER.log(Level.DEBUG, "Using the default locale[{0}]", locale.toString());
              } else {
                  LOGGER.log(Level.DEBUG, "Got locale[{0}] from request.", locale.toString());
              }
          } else {
              LOGGER.log(Level.DEBUG, "Got locale[{0}] from session.", locale.toString());
          }
  
          return locale;
      }
docs: Gets locale with the specified request.
  <p>
  By the following steps:
  <ol>
  <li>Gets from session of the specified request</li>
  <li>Gets from the specified request header</li>
  <li>Using {@link Latkes#getLocale() server configuration}</li>
  </ol>
  
  @param request the specified request
  @return locale