Resource Bundle Editor Plugin: use multiple bundles in one jstl-file

618 views
Skip to first unread message

Edwin B.

unread,
Aug 28, 2015, 7:49:03 AM8/28/15
to Hippo Community
Hi,


What is the best practice when needing two different Resource Bundles [1] in a single jstl-file?

Do I need to set a new basename (hst:setBundle) whenever I have to switch to another bundle?
<hst:setBundle basename="my.project.Labels"/>
<fmt:message key="my_labels_key" />
.
.
<hst:setBundle basename="my.project.OtherLabels"/>
<fmt:message key="my_otherlabels_key" />


Or can I use the bundle-attibute in the fmt:format-tag to pass the basename?
I didn't get this to work, it runs into a warning (Unable to convert string "my.project.OtherLabels" to class "javax.servlet.jsp.jstl.fmt.LocalizationContext" for attribute "bundle": Property Editor not registered with the PropertyEditorManager)

<fmt:message key="my_otherlabels_key" bundle="my.project.OtherLabels" />


Best regards,
Edwin


Woonsan Ko

unread,
Aug 28, 2015, 8:14:47 AM8/28/15
to hippo-c...@googlegroups.com
I think you can do like an example in this page:
- http://www.tutorialspoint.com/jsp/jstl_format_message_tag.htm

Store the bundle with var attribute and use it in bundle attribute of
message tag.

Regards,

Woonsan
> --
> Hippo Community Group: The place for all discussions and announcements
> about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google
> Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hippo-communi...@googlegroups.com
> <mailto:hippo-communi...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.


--
w....@onehippo.com www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

Brian Snijders

unread,
Aug 28, 2015, 8:24:26 AM8/28/15
to hippo-c...@googlegroups.com
Hi Edwin,

Just comma-separate your bundle names. This way, the HST will create a CompositeResourceBundle (please review the tags code for this), essentially a K,V-map of all your labels in all the bundles.

So, in your case, this will work:

<hst:setBundle basename="my.project.Labels,my.project.OtherLabels"/>
<fmt:message key="my_labels_key" />
<fmt:message key="my_otherlabels_key" />

Good luck!
Brian


To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.



--
Met vriendelijke groet,

Brian Snijders

Software Engineer
http://about.me/briansnijders

Finalist -  open IT oplossingen

Rotterdam - Eindhoven - Maarssen
http://www.finalist.nl


Telefoon 088 217 08 43
Mobiel    06 455 40 083

Woonsan Ko

unread,
Aug 28, 2015, 8:29:15 AM8/28/15
to hippo-c...@googlegroups.com
That's great! I forgot that hst:setBundle can do that! :)

Cheers!

Woonsan

On 8/28/15 8:24 AM, Brian Snijders wrote:
> Hi Edwin,
>
> Just comma-separate your bundle names. This way, the HST will create a
> CompositeResourceBundle (please review the tags code for this),
> essentially a K,V-map of all your labels in all the bundles.
>
> So, in your case, this will work:
>
> |
> <hst:setBundle basename="my.project.Labels,|my.project.OtherLabels|"/>
> <fmt:message key="my_labels_key" />
> <fmt:message key="my_otherlabels_key" />
> |
>
> Good luck!
> Brian
>
>
> 2015-08-28 14:14 GMT+02:00 Woonsan Ko <w....@onehippo.com
> <mailto:w....@onehippo.com>>:
> <mailto:hippo-c...@googlegroups.com>
> > RSS:
> >
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Hippo Community" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to hippo-communi...@googlegroups.com
> <mailto:hippo-community%2Bunsu...@googlegroups.com>
> > <mailto:hippo-communi...@googlegroups.com
> <mailto:hippo-community%2Bunsu...@googlegroups.com>>.
> > Visit this group at http://groups.google.com/group/hippo-community.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> w....@onehippo.com <mailto:w....@onehippo.com> www.onehippo.com
> <http://www.onehippo.com>
> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 <tel:%2B1%20877%20414%204776> (toll free)
> Europe +31(0)20 522 4466 <tel:%2B31%280%2920%20522%204466>
>
> --
> Hippo Community Group: The place for all discussions and
> announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to
> hippo-c...@googlegroups.com
> <mailto:hippo-c...@googlegroups.com>
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google
> Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to hippo-communi...@googlegroups.com
> <mailto:hippo-community%2Bunsu...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Met vriendelijke groet,
>
> Brian Snijders
> Software Engineer
> http://about.me/briansnijders
>
> Finalist - open *IT* oplossingen
> Rotterdam - Eindhoven - Maarssen
> http://www.finalist.nl__
>
> Telefoon 088 217 08 43
> Mobiel 06 455 40 083
>

Edwin B.

unread,
Aug 31, 2015, 3:08:28 AM8/31/15
to Hippo Community
Hi,

The suggestion Woonsan (store the bundle with var attribute and use it in bundle attribute of message tag) works best for me.
In that case I don't need to worry about duplicate keys in different bundles.

Best regards,
Edwin
Reply all
Reply to author
Forward
0 new messages