Class DefaultLocaleManager
- java.lang.Object
-
- com.atlassian.confluence.impl.locale.DefaultLocaleManager
-
- All Implemented Interfaces:
LocaleManager
public class DefaultLocaleManager extends Object implements LocaleManager
- Since:
- 7.20
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.languages.LocaleManager
DEFAULT_LOCALE
-
-
Constructor Summary
Constructors Constructor Description DefaultLocaleManager(GlobalSettingsManager settingsManager, UserPreferencesAccessor userPreferencesAccessor, UserExistenceChecker userExistenceChecker, LanguageManager languageManager, com.atlassian.cache.CacheFactory cacheFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Locale
getLocale(com.atlassian.user.User user)
Returns the user's locale if they have one set in their preferences, otherwise returns the site default locale.@NonNull LocaleInfo
getLocaleInfo(@Nullable com.atlassian.user.User user)
Locale
getSiteDefaultLocale()
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 Detail
-
DefaultLocaleManager
public DefaultLocaleManager(GlobalSettingsManager settingsManager, UserPreferencesAccessor userPreferencesAccessor, UserExistenceChecker userExistenceChecker, LanguageManager languageManager, com.atlassian.cache.CacheFactory cacheFactory)
-
-
Method Detail
-
invalidateLocaleInfoCache
public final void invalidateLocaleInfoCache(@Nullable com.atlassian.user.User user)
- Specified by:
invalidateLocaleInfoCache
in interfaceLocaleManager
-
getLocaleInfo
public final @NonNull LocaleInfo getLocaleInfo(@Nullable com.atlassian.user.User user)
- Specified by:
getLocaleInfo
in interfaceLocaleManager
- Returns:
- a locale info with requested , selected and selection reason
-
getLocale
public Locale getLocale(com.atlassian.user.User user)
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
public Locale getSiteDefaultLocale()
- Specified by:
getSiteDefaultLocale
in interfaceLocaleManager
- Returns:
- The default site locale, or
LocaleManager.DEFAULT_LOCALE
if none is set.
-
setRequestLanguages
public void setRequestLanguages(String languageString)
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
public void setLanguage(String language)
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
-
-