Interface LocaleResolver

All Known Implementing Classes:
AcceptLanguageLocaleResolver, CompositeLocaleResolver, SessionLocaleResolver, UrlLocaleResolver

public interface LocaleResolver
Strategy interface for resolving a Locale from an HTTP request.

Implementations determine the user's locale using various sources such as the browser's Accept-Language header, session attributes, URL path prefixes, or a combination thereof.

A resolver may return null to indicate that it has no opinion, allowing a CompositeLocaleResolver to try the next resolver in the chain. The LocaleConfiguration applies a final fallback if all resolvers return null.

Usage:


 // Configure in Application.initialize()
 LocaleConfiguration.setLocaleResolver(new SessionLocaleResolver());

 // Or chain multiple resolvers
 CompositeLocaleResolver chain = new CompositeLocaleResolver();
 chain.addResolver(new SessionLocaleResolver());
 chain.addResolver(new AcceptLanguageLocaleResolver());
 LocaleConfiguration.setLocaleResolver(chain);
 
Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Resolves the locale for the given HTTP request.
  • Method Details

    • resolveLocale

      Locale resolveLocale(OorianHttpRequest request)
      Resolves the locale for the given HTTP request.
      Parameters:
      request - the current HTTP request
      Returns:
      the resolved locale, or null if this resolver cannot determine one