Spring Framework AcceptHeaderLocaleResolver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AcceptHeaderLocaleResolver class.

This code example shows how to use the following methods:
 * @author Felix Gnass [fgnass at neteye dot de] 
 * @since 6.5 
 */ 
public abstract class ChainedLocaleResolver implements LocaleResolver { 
 
	private LocaleResolver fallbackResolver = new AcceptHeaderLocaleResolver(); 
	 
	public void setFallbackResolver(LocaleResolver fallbackResolver) { 
		Assert.notNull(fallbackResolver, "Fallback LocaleResolver must not be null"); 
		this.fallbackResolver = fallbackResolver; 
	} 
 
	public final Locale resolveLocale(HttpServletRequest request) { 
		Locale locale = resolveLocaleInternal(request); 
		if (locale == null) { 
			locale = fallbackResolver.resolveLocale(request); 
		} 
		return locale; 
	} 
	 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
/** 
 * Alfresco specific extension of Spring AcceptHeaderLocaleResolver. 
 *  
 * @author kevinr 
 */ 
public class LocaleResolver extends AcceptHeaderLocaleResolver  
{ 
    @Override 
    public Locale resolveLocale(HttpServletRequest request)  
    { 
        Locale locale = Locale.getDefault(); 
         
        // set language locale from browser header if available 
        final String acceptLang = request.getHeader("Accept-Language"); 
        if (acceptLang != null && acceptLang.length() != 0) 
        { 
           StringTokenizer t = new StringTokenizer(acceptLang, ",; "); 
            
           // get language and convert to java locale format 
           String language = t.nextToken().replace('-', '_'); 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java