Delivery Tier I18N Support
Note: For dynamic internationalization (I18N) that you can manage through the CMS, use Dynamic Resource Bundles.
This page describes how to configure I18N support in the delivery tier (HST) of Bloomreach Content.
Overview
The delivery tier supports static I18N using Java resource bundles and configuration in the virtual hosts. The locale is determined automatically based on the configuration, so you do not need to set it manually in templates.
Implementation Steps
1. Configure the Localization Context
Add the following context parameter to site/webapp/src/main/webapp/WEB-INF/web.xml:
<!-- I18N --> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>messages</param-value> </context-param>
2. Add Resource Bundles
Create property files for each locale in site/components/src/main/resources. For example:
messages_en_US.properties
home.title=Home
messages_nl_NL.properties
home.title=Thuis
3. Configure the Default Locale
Set the default locale in the virtual hosts configuration using the Console. For example:
/hst:myproject/hst:hosts: /hst:locale: en_US
4. Configure Locale per Mount (Optional)
You can override the locale for a specific mount. For example, to set Dutch for the /nl mount:
/hst:myproject/hst:hosts/dev-localhost/localhost/hst:root/nl: /hst:locale: nl_NL
5. Use I18N in Templates
You can use the fmt:message tag in your frontend templates. The delivery tier sets the locale automatically based on your configuration.
JSP Example
<fmt:message key="home.title"/>
Freemarker Example
<@fmt.message key="home.title"/>
Important Considerations
- Do not use
<fmt:setLocale value="some_locale" scope="page | request | session | application"/>in templates. The delivery tier manages the locale automatically. - The only exception is for RSS feeds, which must always use the
en-USlocale. In this case, set the locale explicitly:<fmt:setLocale value="en-US"/>