Make a Channel's Default Resource Bundle IDs Configurable in the Channel Manager
Introduction
Goal
Enable users the manage a channel's resource bundle IDs through the Channel Settings dialog in the Channel Manager.
Background
Hippo CMS's delivery tier supports localization through resource bundles. A default resource bundle ID (or multiple IDs) can be specified at in the delivery tier configuration at virtual host group, virtual host, or mount level. In addition, developers can define the default resource bundle IDs as a channel parameter in their implementation project, to enable end-users to change the parameter in the Channel Manager through a channel's Settings dialog. The channel parameter can be annotated with UI directives as usual.
This page explains how to define the default resource bundle IDs as a channel parameter.
Define Default Resource Bundle IDs as Channel Parameter
Define a ChannelInfo interface as explained in Define a Channel's Configuration Parameters.
Add a method getDefaultResourceBundleIds to the interface and annotate it with @Parameter with name hst:defaultresourcebundleid:
package org.example.channels; import org.hippoecm.hst.configuration.channel.ChannelInfo; import org.hippoecm.hst.core.parameters.FieldGroup; import org.hippoecm.hst.core.parameters.FieldGroupList; import org.hippoecm.hst.core.parameters.Parameter; @FieldGroupList({ @FieldGroup( titleKey = "fields.channel", value = { "hst:defaultresourcebundleid" } ) }) public interface WebsiteInfo extends ChannelInfo { @Parameter( name = "hst:defaultresourcebundleid", required = false, defaultValue="org.example.labels.Messages") String getDefaultResourceBundleIds(); }
Add localized UI labels for the interface at /hippo:configuration/hippo:translations/hippo:hst/channelparameters:
definitions: config: /hippo:configuration/hippo:translations/hippo:hst/channelparameters: jcr:primaryType: hipposys:resourcebundles /org: jcr:primaryType: hipposys:resourcebundles /example: jcr:primaryType: hipposys:resourcebundles /channels: jcr:primaryType: hipposys:resourcebundles /WebsiteInfo: jcr:primaryType: hipposys:resourcebundles /en: jcr:primaryType: hipposys:resourcebundle fields.channel: Channel Settings hst:defaultresourcebundleid: Default Resource Bundle IDs
The default resource bundle ID can then be configured in a channel's Settings dialog. Multiple resource bundle IDs can be specified as comma-separated.