Interface LocaleResolver


public interface LocaleResolver
This interface is responsible for resolving the current locale.
Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Resolve the set Application Locale that should be used in internationalization and localization.
    Resolve the Locale that should be used in internationalization and localization.
    getLocale(UserKey userKey)
    Resolve the Locale that should be used in internationalization and localization.
    getLocale(javax.servlet.http.HttpServletRequest request)
    Given a request, resolve the Locale that should be used in internationalization and localization.
    Returns a set of all the supported locales by the host application.
  • Method Details

    • getLocale

      Locale getLocale(javax.servlet.http.HttpServletRequest request)
      Given a request, resolve the Locale that should be used in internationalization and localization. The locale should be determined by first checking the remote users preferences, then defaulting to the application default locale if no preferred locale is set. May consult the given request for the preferred browser locales (if supported by the product).
      Parameters:
      request - Request to check
      Returns:
      Locale to be used in i18n and l10n. Locale.getDefault() if none found.
    • getLocale

      Locale getLocale()
      Resolve the Locale that should be used in internationalization and localization. The locale should be determined by checking the preferences of the user in the current authentication context if available, then default to the application default locale if no preferred locale is set. May consult the current request for the preferred browser locales (if supported by the product).
      Returns:
      Locale to be used in i18n and l10n. Locale.getDefault() if none found.
    • getLocale

      Locale getLocale(@Nullable UserKey userKey)
      Resolve the Locale that should be used in internationalization and localization. The locale should be determined by checking the preferences of the given user. If no user is given, or the user cannot be found, or the user does not have any preferred locale, then default to the application default locale. Must not consult the current request for any preferred browser locales.
      Parameters:
      userKey - the user. Can be null.
      Returns:
      Locale to be used in i18n and l10n. Locale.getDefault() if none found.
      Since:
      2.10
    • getApplicationLocale

      Locale getApplicationLocale()
      Resolve the set Application Locale that should be used in internationalization and localization. The locale returned is the current application locale (also known as a system/site locale) or the default locale if no current application locale is set. Must not consider current user locale. Must not consult the current request for any preferred browser locales.
      Returns:
      Locale to be used in i18n and l10n. Locale.getDefault() if none found.
      Since:
      4.4.0
    • getSupportedLocales

      Set<Locale> getSupportedLocales()
      Returns a set of all the supported locales by the host application. This is all the language packs that are installed.
      Returns:
      an unmodifiable set of all the supported locales by the host application. Must contain at least one locale.