Dynamic Resource Bundle Node Structure
Resource Bundle Documents in the Content Repository
The content type of resource bundle documents is defined as follows:
[resourcebundle:resourcebundle] > hippo:document, hippostd:publishableSummary, hippostdpubwf:document orderable - resourcebundle:id (string) mandatory - resourcebundle:keys (string) multiple - resourcebundle:messages (string) multiple - * (string) - * (string) multiple
Here's an explanation for each property:
Property Definition | Type | Description | Example values |
resourcebundle:id | string |
The basename of the resource bundle which this resource bundle document is defining. |
org.example.app.Messages |
resourcebundle:keys | string, multiple | Array of resource bundle keys. This property values are equivalent to all the property key names in a properties resource bundle file, for instance. Note: each item of this value array should map to each item of the value array of "resourcebundle:messages" property. |
{ "greeting.one", "greeting.two" } |
resourcebundle:messages | string, multiple | Array of resource bundle messages for the default locale. This property values are equivalent to all the property values in a properties resource bundle file, for instance. Note: each item of this value array should map to each item of the value array of "resourcebundle:keys" property. |
{ "Hello!", "Hippo!" } |
* (string) | string | This property exists for any potential extension points. For example, you might want to put some custom properties for your specific needs, for instance. | - "myproject:specialkey" = "special" |
* (string) multiple | string, multiple |
This property exists to store localized resource bundle messages. For example, if you want to support the locales, "en_US", "fr" and "nl_NL" specifically, then you should add the following property: And, you should add localized resource bundle messages for each locale in these properties. |
- "resourcebundle:messages_en_US" = { "Hello!","Hippo!" } - "resourcebundle:messages_fr" = { "Bonjour!", "Hippo!" } - "resourcebundle:messages_nl_NL" = { "Hallo!", "Hippo!" } |
Please note that you can add documents in any location by the resourcebundle:resourcebundle content node type, but you should keep the resourcebundle:id property unique throughout the repository because the resourcebundle:id property value is used when looking up the resource bundle by the basename.
Also, you can set the message keys and the default locale messages in resourcebundle:keys and resourcebundle:messages properties, and you have to add localized messages in a separated properties named in the pattern, resourcebundle:message_${locale.name}, where ${locale.name} must be replaced by the real locale name such as en_US, fr, nl_NL, etc.
Each value item of resourcebundle:keys property must match with each value item of resourcebundle:messages and resourcebundle:messages_* properties. Otherwise, the mismatch will be logged as errors without proceeding.
Here's an example resource bundle document contents. This is excerpt from https://code.onehippo.org/cms-community/hippo-testsuite/blob/hippo-testsuite-3.2.2/content/src/main/resources/resourcebundles.xml and it has two variants for both live and preview under the document handle node:
<?xml version="1.0" encoding="UTF-8"?> <sv:node sv:name="productresources" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>hippo:handle</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>hippo:hardhandle</sv:value> </sv:property> <sv:node sv:name="productresources"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>resourcebundle:resourcebundle</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>hippo:harddocument</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="hippo:availability" sv:type="String"> <sv:value>live</sv:value> </sv:property> <!-- SNIP --> <sv:property sv:name="hippostd:state" sv:type="String"> <sv:value>published</sv:value> </sv:property> <sv:property sv:name="resourcebundle:id" sv:type="String"> <sv:value>org.onehippo.hst.demo.resources.ProductResources</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:keys" sv:type="String"> <sv:value>brand</sv:value> <sv:value>product</sv:value> <sv:value>type</sv:value> <sv:value>color</sv:value> <sv:value>price</sv:value> <sv:value>tags</sv:value> <sv:value>image</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:messages" sv:type="String"> <sv:value>Brand</sv:value> <sv:value>Product</sv:value> <sv:value>Type</sv:value> <sv:value>Color</sv:value> <sv:value>Price</sv:value> <sv:value>Tags</sv:value> <sv:value>Image</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:messages_en" sv:type="String"> <sv:value>Brand</sv:value> <sv:value>Product</sv:value> <sv:value>Type</sv:value> <sv:value>Color</sv:value> <sv:value>Price</sv:value> <sv:value>Tags</sv:value> <sv:value>Image</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:messages_fr" sv:type="String"> <sv:value>Marque</sv:value> <sv:value>Produit</sv:value> <sv:value>Type</sv:value> <sv:value>Couleur</sv:value> <sv:value>Prix</sv:value> <sv:value>Balises</sv:value> <sv:value>Image</sv:value> </sv:property> </sv:node> <sv:node sv:name="productresources"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>resourcebundle:resourcebundle</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>hippo:harddocument</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="hippo:availability" sv:type="String"> <sv:value>preview</sv:value> </sv:property> <!-- SNIP --> <sv:property sv:name="hippostd:state" sv:type="String"> <sv:value>unpublished</sv:value> </sv:property> <sv:property sv:name="resourcebundle:id" sv:type="String"> <sv:value>org.onehippo.hst.demo.resources.ProductResources</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:keys" sv:type="String"> <sv:value>brand</sv:value> <sv:value>product</sv:value> <sv:value>type</sv:value> <sv:value>color</sv:value> <sv:value>price</sv:value> <sv:value>tags</sv:value> <sv:value>image</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:messages" sv:type="String"> <sv:value>Brand</sv:value> <sv:value>Product</sv:value> <sv:value>Type</sv:value> <sv:value>Color</sv:value> <sv:value>Price</sv:value> <sv:value>Tags</sv:value> <sv:value>Image</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:messages_en" sv:type="String"> <sv:value>Brand</sv:value> <sv:value>Product</sv:value> <sv:value>Type</sv:value> <sv:value>Color</sv:value> <sv:value>Price</sv:value> <sv:value>Tags</sv:value> <sv:value>Image</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="resourcebundle:messages_fr" sv:type="String"> <sv:value>Marque</sv:value> <sv:value>Produit</sv:value> <sv:value>Type</sv:value> <sv:value>Couleur</sv:value> <sv:value>Prix</sv:value> <sv:value>Balises</sv:value> <sv:value>Image</sv:value> </sv:property> </sv:node> </sv:node>
Please note that the HST Resource Bundle feature supports context awareness based on preview or live mode. So, if you visit a preview mode site, then resource bundles are automatically selected only from the preview variants of resource bundle documents. If you visit a live mode site, then resource bundles are automatically selected only from the live variants of resource bundle documents.