SeamFramework.orgCommunity Documentation

Chapter 37. Locales

37.1. Application Locale
37.2. User Locale
37.3. Available Locales

In a similar fashion to TimeZones we have an Application Locale:


private java.util.Locale lc;

accessible via EL with "defaultLocale".

By default the Locale will be set to the JVM default, unless you produce a String annotated with @DefaultLocale. This can be achieved through either the Seam Config module, with any bean that @Produces a method or field that matches the type and qualifier.

This will set the application language to be English with the country of US:


private String defaultLocaleKey = "en_US";

As you can see from the previous example, you can define the Locale with lang_country_variant. It's important to note that the first two parts of the locale definition are not expected to be greater than 2 characters otherwise an error will be produced and it will default to the JVM Locale.

The Locale associated with the User Session can be retrieved by:


private java.util.Locale locale;

which is EL accessible via userLocale.

By default the Locale will be that of the Application when the User Session is initialized. However, changing the User's Locale is a simple matter of firing an event to update it. An example would be:


private Event<java.util.Locale> localeEvent;
public void setUserLocale() {
    Locale canada = Locale.CANADA;;

We've also provided a list of available Locales that can be accessed via:


private List<java.util.Locale> locales;

The locales that will be returned as available can be defined by extending LocaleConfiguration. As seen here:

public class CustomLocaleConfiguration extends LocaleConfiguration {

    public void setup() {