Localization
Note
This section describes using resource bundles to customize the front end. For information about using resource bundles to customize Brightspot's widgets, dashboard, reports, and other editorial components, see Customizing Brightspot's labels.
You can use resource bundles along with the {{format}}
helper to display localized text in published content. This deployment requires a single template, a resource bundle for each locale, and an optional data file.
At runtime, Brightspot displays localized text using the following logic:
Extract the site from the received URL.
Determine the site's locale.
Retrieve the template for the requested item.
Populate the template's helpers using the standard view-model logic. However, when processing
{{format}}
helpers:Look up the properties file for the site's locale.
Within the properties file, look up the string to evaluate and return.
The following snippets provide an example for localization with the {{format}}
helper. All of the snippets in this example are in the same directory.
{{!-- File name AuthorPage.hbs --}} <div> <h3 class="author-headline">{{format "aboutme"}}</h3> 1 </div>
Performs a call to message formatter |
The default properties file has a name AuthorPage.properties
, and the localized properties file has a name AuthorPage_xx.properties
.
The literal
AuthorPage
is mandatory because it must match the name of the template.The two letters before
.properties
must be a language code that Java recognizes. For a list of two-letter language codes, see Codes for the Representation of Names of Languages.Example:
AuthorPage_fr.properties
# File name AuthorPage.properties aboutme=My Recent History
The previous snippet is in a file AuthorPage.properties
. This is the default properties file for localization. If there is no locale associated with the site, or if there is no properties file for the site's locale, Brightspot renders the output using this file.
# File name AuthorPage_fr.properties aboutme=Mon Histoire Récente
The previous snippet is in a file AuthorPage_fr.properties
. When Brightspot detects that the published site's locale is French, it looks up the value for {{format "aboutme"}}
in this file.
<div> <h3 class="author-headline">Mon Histoire Récente</h3> </div>
The previous snippet shows the resulting HTML output for localized text from the {{format"aboutme"}}
helper.