Make sure you set only one locale with the DEFAULT_FLAG set to true. We recommend you keep the default locale insert statement in load_content_structure.sql for clarity.

Language Specific Locale

There are cases where two locales use the same langauge, albeit with differences in certains words and phrases. In these cases, you can set a language only locale then tag your contet with 'en' or 'es'. By doing this you can, for example, have a general set for all english, and then only tag specific content that varies with the UK version.

Locale Resolver

Broadleaf Commerce relies on the BroadleafRequestContext to carry the locale information by using the BroadleafLocaleResolver to insert it into. We go through the following series of checks to resolve the locale.

We have set "blLocale" to be the name of the attribute that will be set and checked for.

Request Attribute

We check for a request attribute as a first check to allow implementers to to easily override the session variable.

request.getAttribute("blLocale")

Request Parameter

We then check for a request parameter.

request.getParameter("blLocale")

Session

The Heat Clinic demo site is using the session variable to set the locale.

session.getAttribute("blLocale")

Default

If none of the above methods find a locale, we use the default that has been defined in the database.

Once we go through the checks, we set the locale to the session to enable the site to remain in the selected locale.

request.getSession().setAttribute("blLocale",locale);

Using the Locales

Now that we have our locales setup in our database and have our locale resolver, we can access them passing in the sesssion attribute.

In the links below, we are adding ?blLocaleCode=en_US, this allows the Locale Resolver to come in, grab the attribute from the session, and set in the BroadleafRequestContext.