public class AvailableLocaleResolver extends java.lang.Object
The locales an application is actually translated into, for driving a language selector.
Unlike java.util.Locale#getAvailableLocales(), which lists every locale the JVM knows, this lists only locales that have a message bundle, plus the configured default locale.
The locales come from the same EffectiveI18nDescriptors that produce
spring.messages.basename, so a plugin excluded from message resolution — evicted, filtered
out by environment, or failed to load — cannot advertise its language here either. Offering a
translation whose messages do not resolve would be worse than not offering it.
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
DEFAULT_BASE_NAME |
The base name of an application's own message bundles (messages.properties). |
| Constructor and description |
|---|
AvailableLocaleResolver(java.util.function.Supplier<EffectiveI18nDescriptors> descriptors, java.util.Locale defaultLocale)
|
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
clearCache()Discards the cached list so the next getAvailableLocales() re-reads the descriptors. |
|
public java.util.List<java.util.Locale> |
getAvailableLocales()
|
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
The base name of an application's own message bundles (messages.properties).
descriptors - supplies the effective descriptors; re-invoked after clearCache()
so that a descriptor regenerated during development is picked updefaultLocale - the locale of the base bundle, always included (may be null)Discards the cached list so the next getAvailableLocales() re-reads the descriptors.
During development the Grails Gradle plugin regenerates the descriptor when a bundle is added or removed, so a re-read picks up a newly translated language without a restart.