View Javadoc

1   package com.atlassian.sal.api.message;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import java.util.Locale;
5   import java.util.Set;
6   
7   /**
8    * This interface is responsible for resolving the current locale.
9    *
10   * @since 2.0
11   */
12  public interface LocaleResolver
13  {
14      /**
15       * Given a request, resolve the {@link Locale} that should be used in internationalization and localization.
16       * The locale should be determined by first checking the remote users preferences, then defaulting to the
17       * application default locale if no preferred locale is set.
18       *
19       * @param request Request to check 
20       * @return Locale to be used in i18n and l10n. {@link Locale#getDefault()} if none found.
21       */
22      Locale getLocale(HttpServletRequest request);
23  
24      /**
25       * Resolve the Locale that should be used in internationalization and localization.  The
26       * locale should be determined by checking the preferences of the user in the current authentication
27       * context if available, then default to the application default locale if no preferred locale is set. 
28       * @return Locale to be used in i18n and l10n. {@link Locale#getDefault()} if none found.
29       */
30      Locale getLocale();
31      
32      /**
33       * Returns a set of all the supported locales by the host application. This is all the language packs that
34       * are installed.
35       *
36       * @return an unmodifiable set of all the supported locales by the host application. Must contain at least one locale.
37       */
38      Set<Locale> getSupportedLocales();
39  }