code: private static Locale getLocaleForRequest(HttpServletRequest req) {
  
          CmsAcceptLanguageHeaderParser parser = new CmsAcceptLanguageHeaderParser(
              req,
              OpenCms.getWorkplaceManager().getDefaultLocale());
          List<Locale> acceptedLocales = parser.getAcceptedLocales();
          List<Locale> workplaceLocales = OpenCms.getWorkplaceManager().getLocales();
          Locale locale = OpenCms.getLocaleManager().getFirstMatchingLocale(acceptedLocales, workplaceLocales);
          if (locale == null) {
              // no match found - use OpenCms default locale
              locale = OpenCms.getWorkplaceManager().getDefaultLocale();
          }
          return locale;
      }
docs: Returns the locale for the given request.<p>
  
  @param req the request
  
  @return the locale