public static Collection < Locale > getLocales ( final HttpServletRequest req ) { if ( req . getHeader ( "Accept-Language" ) == null ) { return null ; } @ SuppressWarnings ( "unchecked" ) Enumeration < Locale > lcs = req . getLocales ( ) ; ArrayList < Locale > locales = new ArrayList < Locale > ( ) ; while ( lcs . hasMoreElements ( ) ) { locales . add ( lcs . nextElement ( ) ) ; } return locales ; }
If there is no Accept - Language header returns null otherwise returns a collection of Locales ordered with preferred first .