Class DefaultLocaleManager
java.lang.Object
com.atlassian.confluence.impl.locale.DefaultLocaleManager
- All Implemented Interfaces:
LocaleManager
- Since:
- 7.20
-
Field Summary
Fields inherited from interface com.atlassian.confluence.languages.LocaleManager
DEFAULT_LOCALE
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultLocaleManager
(GlobalSettingsManager settingsManager, UserPreferencesAccessor userPreferencesAccessor, UserExistenceChecker userExistenceChecker, LanguageManager languageManager, com.atlassian.cache.CacheFactory cacheFactory, com.atlassian.config.ApplicationConfiguration applicationConfig) -
Method Summary
Modifier and TypeMethodDescriptiongetLocale
(com.atlassian.user.User user) Returns the user's locale if they have one set in their preferences, otherwise returns the site default locale.final @NonNull LocaleInfo
getLocaleInfo
(@Nullable com.atlassian.user.User user) final void
invalidateLocaleInfoCache
(@Nullable com.atlassian.user.User user) void
setLanguage
(String language) Should set the language string as given by Locale (en-gb for example) in a THREAD LOCAL cache.void
setRequestLanguages
(String languageString) Should set the language string from the request in a THREAD LOCAL cache.
-
Constructor Details
-
DefaultLocaleManager
public DefaultLocaleManager(GlobalSettingsManager settingsManager, UserPreferencesAccessor userPreferencesAccessor, UserExistenceChecker userExistenceChecker, LanguageManager languageManager, com.atlassian.cache.CacheFactory cacheFactory, com.atlassian.config.ApplicationConfiguration applicationConfig)
-
-
Method Details
-
invalidateLocaleInfoCache
public final void invalidateLocaleInfoCache(@Nullable com.atlassian.user.User user) - Specified by:
invalidateLocaleInfoCache
in interfaceLocaleManager
-
getLocaleInfo
- Specified by:
getLocaleInfo
in interfaceLocaleManager
- Returns:
- a locale info with requested , selected and selection reason
-
getLocale
Returns the user's locale if they have one set in their preferences, otherwise returns the site default locale. Caches the result in the thread-local cache so we only check the preference or settings once per request.- Specified by:
getLocale
in interfaceLocaleManager
-
getSiteDefaultLocale
- Specified by:
getSiteDefaultLocale
in interfaceLocaleManager
- Returns:
- The default site locale, or
LocaleManager.DEFAULT_LOCALE
if none is set.
-
setRequestLanguages
Description copied from interface:LocaleManager
Should set the language string from the request in a THREAD LOCAL cache.- Specified by:
setRequestLanguages
in interfaceLocaleManager
- Parameters:
languageString
- comma- or semicolon-separated languages
-
setLanguage
Description copied from interface:LocaleManager
Should set the language string as given by Locale (en-gb for example) in a THREAD LOCAL cache. Does nothing if the language string is invalid.- Specified by:
setLanguage
in interfaceLocaleManager
- Parameters:
language
- target language
-