You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Axel Seinsche <st...@seinsche.net> on 2004/04/24 21:48:54 UTC
i18n with keys from DB
Hi all,
I think I have a common problem, but couldn't find any solution in the archive of this list or with Google.
All I want to have is i18n where keys come from the DB. My DB contains a table where I can read the keys from. With this key I want to do a lookup in my properties file. How can I do this? Until now I failed to something like
<bean:message key="<c:out value="my_db_value" />" />
I hope this problem was solved before and someone can help me.
I thougt about storing my values language dependent in the DB, but for several reasons I don't like this approach!
Thanks,
Axel
Re: i18n with keys from DB
Posted by Riyad Kalla <rs...@email.arizona.edu>.
Unfortunately you can't use tags inside of eachother like that, which is
why my code is still spackled with little expressions:
<bean:message key="<%= my_db_value %>" />
You can use an expression language to get around some cases like this
with JSTL, and I think Struts supports the EL as well... I don't know
for sure, I haven't used it.
Axel Seinsche wrote:
>Hi all,
>
>I think I have a common problem, but couldn't find any solution in the archive of this list or with Google.
>
>All I want to have is i18n where keys come from the DB. My DB contains a table where I can read the keys from. With this key I want to do a lookup in my properties file. How can I do this? Until now I failed to something like
>
><bean:message key="<c:out value="my_db_value" />" />
>
>I hope this problem was solved before and someone can help me.
>
>I thougt about storing my values language dependent in the DB, but for several reasons I don't like this approach!
>
>Thanks,
>
>Axel
>
>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: i18n with keys from DB
Posted by "Ruth, Brice" <br...@fiskars.com>.
The easiest think to do is use the struts-bean-el taglib, where you can
do something like this:
<c:set var="myDbVar" value="my_db_value"/>
<bean:message key="${myDbVar}"/>
Basically, store the key in a locally scoped variable (can be page,
session, or request) and then reference that variable in your 'key'
attribute.
We do this all the time for pulling a key from an XML file (or from a
Tiles attribute) and then using the key for bean:message
Cheers!
Axel Seinsche wrote:
>Hi all,
>
>I think I have a common problem, but couldn't find any solution in the archive of this list or with Google.
>
>All I want to have is i18n where keys come from the DB. My DB contains a table where I can read the keys from. With this key I want to do a lookup in my properties file. How can I do this? Until now I failed to something like
>
><bean:message key="<c:out value="my_db_value" />" />
>
>I hope this problem was solved before and someone can help me.
>
>I thougt about storing my values language dependent in the DB, but for several reasons I don't like this approach!
>
>Thanks,
>
>Axel
>
>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>