Skip to content
Mrdigs edited this page Apr 8, 2014 · 5 revisions

All label attributes have built in support for localization.

The label contents are looked up in a ResourceBundle called 'BootstrapLabels' for the user's request locale. As usual with a ResourceBundle, the default bundle is looked up if none exists for a given locale. The key used for the look up is the label text, lowercased, with any spaces replaced with underscores.

If the lookup returns nothing then the label text is used unchanged. There is no ResourceBundle file in the distribution and so this is the default result of all lookups.

Which means that if you need to provide localized versions of the labels, then you have a choice of either supplying a default ResourceBundle that will translate all labels to the language of your choice, or locale specific messages for your target users locales. This is useful if you want to use some of the molds that use labels in English when your target language is not.

For example, to translate the yes and no button molds to French, you would create a file in WEB-INF/classes/BootstrapLabels.properties with the content as:

yes=Oui
no=Non

All yes and no buttons will now be in French:

<b:button mold="yes"/>
<b:button mold="no"/>

If you wanted the buttons to remain in English for users whose locale is not French, you would name the file 'BootstrapLabels_fr.properties and the fallback labels will be used for everyone else.

This functionality is provided by the Message tag, which you can also use directly:

<b:message value="Yes"/>
Clone this wiki locally