public static Enumeration getRequestLocales(HttpServletRequest request) {
        Enumeration values = request.getHeaders("accept-language");
        if (values.hasMoreElements()) {
            // At least one "accept-language". Simply return
            // the enumeration returned by request.getLocales().
            // System.out.println("At least one accept-language");
            return request.getLocales();
        } else {
            // No header for "accept-language". Simply return
            // the empty enumeration.
            // System.out.println("No accept-language");
            return values;
        }
    }
public static Enumeration getRequestLocales ( HttpServletRequest request ) { Enumeration values = request . getHeaders ( "accept-language" ) ; if ( values . hasMoreElements ( ) ) { return request . getLocales ( ) ; } else { return values ; } }
HttpServletRequest.getLocales() returns the server's default locale if
the request did not specify a preferred language. We do not want this
behavior, because it prevents us from using the fallback locale. We
therefore need to return an empty Enumeration if no preferred locale has
been specified. This way, the logic for the fallback locale will be able
to kick in.