You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by j alex <st...@gmail.com> on 2009/09/04 21:48:43 UTC

[S2] i18n for lists/maps

Hi,

Normally, we use the resource bundles to store Strings like field labels,
error messages etc. But how about things like dropdown display values ? . I
need to i18n-ize an app that has a lot of such dropdowns and the lists are
currently referenced like <s:select name="loanType"
list="#application.dropdownmap['loanType']"/> where dropdownmap is loaded
into ServletContext from a properties file . that has definitions like :
loanType=1~Home Loan|2~Car Loan|3~Refi etc. Here, the 1,2,3 remains constant
but the display value will vary by locale.

It'll be really neat if it's possible to maintain this list in a typical
resource bundle file like ApplicationResources_<locale> and be able to use
it from s:select tags without having to do any manual parsing. Any inputs
will be really helpful.

Thanks!

Re: [S2] i18n for lists/maps

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Exactly. Using the s:select for your example below would be as follows:

<s:select name=²loanType² list=²#{1:getText(key.value1), 2,
getText(key.value2)}²/>

Z.

> Z,
> I'll clarify with a simple example :
> The dropdown must be like :
> 
> <select name="loanType"><option value="1">EnglishType1</option><option
> value="2">EnglishType2</option></select> for EN and <option
> value="1">SpanishType1</option><option value="2">SpanishType2</option>
> 
> So, the values 1 and 2 remain constant, only the text changes. Now, i don't
> want to maintain 1, 2 separately from its text. My understanding from your
> suggestion is to have a list of "Option" objects whose responseKey attribute
> wil hold 1, 2 and responseValue attribute is like "key.value1" ,
> "key.value2" etc. which is defined in properties file as :
> key.value1=EnglishType1
> key.value2=EnglishType2 etc.
> 
> Let me know if i've understood it correctly.
> 
> Thanks,
> Joseph
> 
> 
> 
> I just want to get a couple things straight:
> 
> 1. Your state names are in localised properties files
> 2. The properties files are available to struts2 either via
> struts.custom.i18n.resources or convention (read don¹t ask)
> 
> If you app satisfies these two points then the method I mentioned will work
> fine.  If it doesn¹t, it¹s not that much work to satisfy them.
> 


Re: [S2] i18n for lists/maps

Posted by strutstwouser <st...@gmail.com>.
Z,
I'll clarify with a simple example :
The dropdown must be like : 

<select name="loanType"><option value="1">EnglishType1</option><option
value="2">EnglishType2</option></select> for EN and <option
value="1">SpanishType1</option><option value="2">SpanishType2</option>

So, the values 1 and 2 remain constant, only the text changes. Now, i don't
want to maintain 1, 2 separately from its text. My understanding from your
suggestion is to have a list of "Option" objects whose responseKey attribute
wil hold 1, 2 and responseValue attribute is like "key.value1" ,
"key.value2" etc. which is defined in properties file as : 
key.value1=EnglishType1
key.value2=EnglishType2 etc.

Let me know if i've understood it correctly.

Thanks,
Joseph



I just want to get a couple things straight:

1. Your state names are in localised properties files
2. The properties files are available to struts2 either via
struts.custom.i18n.resources or convention (read don’t ask)

If you app satisfies these two points then the method I mentioned will work
fine.  If it doesn’t, it’s not that much work to satisfy them.


-- 
View this message in context: http://www.nabble.com/-S2--i18n-for-lists-maps-tp25300822p25385065.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] i18n for lists/maps

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
I just want to get a couple things straight:

1. Your state names are in localised properties files
2. The properties files are available to struts2 either via
struts.custom.i18n.resources or convention (read don’t ask)

If you app satisfies these two points then the method I mentioned will work
fine.  If it doesn’t, it’s not that much work to satisfy them.

Where specifically are you seeing a problem?

Z.
> 
> 
> This won't work for me because the list is not maintained in Action, rather
> in a properties file - since it's a set of constants (ex : list of US
> states)
> 
> 
> 
> Sparecreative wrote:
>> > 
>> > You don¹t have to have a DB back end.
>> > 
>> > Here¹s a couple of examples from our system:
>> > 
>> > <s:radio list="responses" listKey="responseKey"
>> > listValue="%{getText(responseValue)}"  name="name"
>> > label="%{getText(responseLabel)}" />
>> > 
>> > <s:select headerKey="" headerValue="%{getText('select')}" list="responses"
>> > listKey="responseKey" listValue="%{getText(responseValue)}"  name="name"
>> > label="%{getText(responseLabel)}" />
>> > 
>> > It¹s pretty self explanatory, but the getText function is called on your
>> > action. Obviously this is predicated on your actions either extending
>> > ActionSupport or implementing a getText method to retrieve localised
>> > values.
>> > 
>> > Z.
>>> >> 
>>> >> 
>>> >> Yeah, i dont want to change to DB backed bundles. My question is if the
>>> >> s:select tag can take a list from a resourcebundle directly and use it .
>>> >> If
>>> >> so, how should the list be specified ?
>>> >> 
>>> >> On Sat, Sep 5, 2009 at 3:59 AM, Tommy Pham <to...@yahoo.com> wrote:
>>> >> 
>>>>> >>> > ----- Original Message ----
>>>>>>> >>>> > > From: j alex <st...@gmail.com>
>>>>>>> >>>> > > To: Struts Users Mailing List <us...@struts.apache.org>
>>>>>>> >>>> > > Sent: Friday, September 4, 2009 12:48:43 PM
>>>>>>> >>>> > > Subject: [S2] i18n for lists/maps
>>>>>>> >>>> > >
>>>>>>> >>>> > > Hi,
>>>>>>> >>>> > >
>>>>>>> >>>> > > Normally, we use the resource bundles to store Strings like
field
>>>>> >>>> labels,
>>>>>>> >>>> > > error messages etc. But how about things like dropdown display
>>>>> >>>> values ?
>> > .
>>>>> >>> > I
>>>>>>> >>>> > > need to i18n-ize an app that has a lot of such dropdowns and
the
>>>>> >>>> lists
>>>>> >>> > are
>>>>>>> >>>> > > currently referenced like
>>>>>>> >>>> > > list="#application.dropdownmap['loanType']"/> where dropdownmap
is
>>>>> >>>> loaded
>>>>>>> >>>> > > into ServletContext from a properties file . that has
>>>>>>> definitions
>>>>> >>>> like :
>>>>>>> >>>> > > loanType=1~Home Loan|2~Car Loan|3~Refi etc. Here, the 1,2,3
remains
>>>>> >>> > constant
>>>>>>> >>>> > > but the display value will vary by locale.
>>>>>>> >>>> > >
>>>>>>> >>>> > > It'll be really neat if it's possible to maintain this list in
a
>>>>> >>>> typical
>>>>>>> >>>> > > resource bundle file like ApplicationResources_and be able to
use
>>>>>>> >>>> > > it from s:select tags without having to do any manual parsing.
Any
>>>>> >>>> inputs
>>>>>>> >>>> > > will be really helpful.
>>>>>>> >>>> > >
>>>>>>> >>>> > > Thanks!
>>>>> >>> >
>>>>> >>> > Hi Alex,
>>>>> >>> >
>>>>> >>> > I don't mean to advice you on adding more complexity to your project
>>>> >>> but
>>>>> >>> > Mike Baranski and I were discussing about using/getting the
>>>> >>> ResourceBundle
>>>>> >>> > from DB backend instead.  He had one working:
>>>>> >>> >
>>>>> >>> > "Here you go, this is what I did.  I don't know if it's the "best"
>>>> >>> way, but
>>>>> >>> > it works:
>>>>> >>> >
>>>>> >>> > http://mikeski.net/site/node/37
>>>>> >>> >
>>>>> >>> > Mike."
>>>>> >>> >
>>>>> >>> > I had planned on using DB backend instead solely so that anyone with
>>>> >>> the
>>>>> >>> > proper privileges via the web UI can add/change the texts.  You only
>>>> >>> need
>>>> >>> to
>>>>> >>> > provide the proper db structure and key for the texts.  If you do
>>>> >>> implement
>>>>> >>> > DB backend, IMHO, I think it will give you more flexibility for the
>>>> >>> future
>>>>> >>> > and less of the menial work ;), especially when they (your boss
>>>>> and/or
>>>>> >>> > client(s)) decide to use additional language.
>>>>> >>> >
>>>>> >>> > Regards,
>>>>> >>> > Tommy
>>>>> >>> >
>>>>> >>> >
>>>>> >>> > 
>>>>> ---------------------------------------------------------------------
>>>>> >>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> >>> > For additional commands, e-mail: user-help@struts.apache.org
>>>>> >>> >
>>>>> >>> >
>> > 
>> > 
>> > 


Re: [S2] i18n for lists/maps

Posted by strutstwouser <st...@gmail.com>.
This won't work for me because the list is not maintained in Action, rather
in a properties file - since it's a set of constants (ex : list of US
states)



Sparecreative wrote:
> 
> You don¹t have to have a DB back end.
> 
> Here¹s a couple of examples from our system:
> 
> <s:radio list="responses" listKey="responseKey"
> listValue="%{getText(responseValue)}"  name="name"
> label="%{getText(responseLabel)}" />
> 
> <s:select headerKey="" headerValue="%{getText('select')}" list="responses"
> listKey="responseKey" listValue="%{getText(responseValue)}"  name="name"
> label="%{getText(responseLabel)}" />
> 
> It¹s pretty self explanatory, but the getText function is called on your
> action. Obviously this is predicated on your actions either extending
> ActionSupport or implementing a getText method to retrieve localised
> values.
> 
> Z.
>> 
>> 
>> Yeah, i dont want to change to DB backed bundles. My question is if the
>> s:select tag can take a list from a resourcebundle directly and use it .
>> If
>> so, how should the list be specified ?
>> 
>> On Sat, Sep 5, 2009 at 3:59 AM, Tommy Pham <to...@yahoo.com> wrote:
>> 
>>> > ----- Original Message ----
>>>> > > From: j alex <st...@gmail.com>
>>>> > > To: Struts Users Mailing List <us...@struts.apache.org>
>>>> > > Sent: Friday, September 4, 2009 12:48:43 PM
>>>> > > Subject: [S2] i18n for lists/maps
>>>> > >
>>>> > > Hi,
>>>> > >
>>>> > > Normally, we use the resource bundles to store Strings like field
>>>> labels,
>>>> > > error messages etc. But how about things like dropdown display
>>>> values ?
> .
>>> > I
>>>> > > need to i18n-ize an app that has a lot of such dropdowns and the
>>>> lists
>>> > are
>>>> > > currently referenced like
>>>> > > list="#application.dropdownmap['loanType']"/> where dropdownmap is
>>>> loaded
>>>> > > into ServletContext from a properties file . that has definitions
>>>> like :
>>>> > > loanType=1~Home Loan|2~Car Loan|3~Refi etc. Here, the 1,2,3 remains
>>> > constant
>>>> > > but the display value will vary by locale.
>>>> > >
>>>> > > It'll be really neat if it's possible to maintain this list in a
>>>> typical
>>>> > > resource bundle file like ApplicationResources_and be able to use
>>>> > > it from s:select tags without having to do any manual parsing. Any
>>>> inputs
>>>> > > will be really helpful.
>>>> > >
>>>> > > Thanks!
>>> >
>>> > Hi Alex,
>>> >
>>> > I don't mean to advice you on adding more complexity to your project
>>> but
>>> > Mike Baranski and I were discussing about using/getting the
>>> ResourceBundle
>>> > from DB backend instead.  He had one working:
>>> >
>>> > "Here you go, this is what I did.  I don't know if it's the "best"
>>> way, but
>>> > it works:
>>> >
>>> > http://mikeski.net/site/node/37
>>> >
>>> > Mike."
>>> >
>>> > I had planned on using DB backend instead solely so that anyone with
>>> the
>>> > proper privileges via the web UI can add/change the texts.  You only
>>> need
>>> to
>>> > provide the proper db structure and key for the texts.  If you do
>>> implement
>>> > DB backend, IMHO, I think it will give you more flexibility for the
>>> future
>>> > and less of the menial work ;), especially when they (your boss and/or
>>> > client(s)) decide to use additional language.
>>> >
>>> > Regards,
>>> > Tommy
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > For additional commands, e-mail: user-help@struts.apache.org
>>> >
>>> >
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--i18n-for-lists-maps-tp25300822p25340692.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] i18n for lists/maps

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
You don¹t have to have a DB back end.

Here¹s a couple of examples from our system:

<s:radio list="responses" listKey="responseKey"
listValue="%{getText(responseValue)}"  name="name"
label="%{getText(responseLabel)}" />

<s:select headerKey="" headerValue="%{getText('select')}" list="responses"
listKey="responseKey" listValue="%{getText(responseValue)}"  name="name"
label="%{getText(responseLabel)}" />

It¹s pretty self explanatory, but the getText function is called on your
action. Obviously this is predicated on your actions either extending
ActionSupport or implementing a getText method to retrieve localised values.

Z.
> 
> 
> Yeah, i dont want to change to DB backed bundles. My question is if the
> s:select tag can take a list from a resourcebundle directly and use it . If
> so, how should the list be specified ?
> 
> On Sat, Sep 5, 2009 at 3:59 AM, Tommy Pham <to...@yahoo.com> wrote:
> 
>> > ----- Original Message ----
>>> > > From: j alex <st...@gmail.com>
>>> > > To: Struts Users Mailing List <us...@struts.apache.org>
>>> > > Sent: Friday, September 4, 2009 12:48:43 PM
>>> > > Subject: [S2] i18n for lists/maps
>>> > >
>>> > > Hi,
>>> > >
>>> > > Normally, we use the resource bundles to store Strings like field
>>> labels,
>>> > > error messages etc. But how about things like dropdown display values ?
.
>> > I
>>> > > need to i18n-ize an app that has a lot of such dropdowns and the lists
>> > are
>>> > > currently referenced like
>>> > > list="#application.dropdownmap['loanType']"/> where dropdownmap is
>>> loaded
>>> > > into ServletContext from a properties file . that has definitions like :
>>> > > loanType=1~Home Loan|2~Car Loan|3~Refi etc. Here, the 1,2,3 remains
>> > constant
>>> > > but the display value will vary by locale.
>>> > >
>>> > > It'll be really neat if it's possible to maintain this list in a typical
>>> > > resource bundle file like ApplicationResources_and be able to use
>>> > > it from s:select tags without having to do any manual parsing. Any
>>> inputs
>>> > > will be really helpful.
>>> > >
>>> > > Thanks!
>> >
>> > Hi Alex,
>> >
>> > I don't mean to advice you on adding more complexity to your project but
>> > Mike Baranski and I were discussing about using/getting the ResourceBundle
>> > from DB backend instead.  He had one working:
>> >
>> > "Here you go, this is what I did.  I don't know if it's the "best" way, but
>> > it works:
>> >
>> > http://mikeski.net/site/node/37
>> >
>> > Mike."
>> >
>> > I had planned on using DB backend instead solely so that anyone with the
>> > proper privileges via the web UI can add/change the texts.  You only need
>> to
>> > provide the proper db structure and key for the texts.  If you do implement
>> > DB backend, IMHO, I think it will give you more flexibility for the future
>> > and less of the menial work ;), especially when they (your boss and/or
>> > client(s)) decide to use additional language.
>> >
>> > Regards,
>> > Tommy
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >


Re: [S2] i18n for lists/maps

Posted by j alex <st...@gmail.com>.
Yeah, i dont want to change to DB backed bundles. My question is if the
s:select tag can take a list from a resourcebundle directly and use it . If
so, how should the list be specified ?

On Sat, Sep 5, 2009 at 3:59 AM, Tommy Pham <to...@yahoo.com> wrote:

> ----- Original Message ----
> > From: j alex <st...@gmail.com>
> > To: Struts Users Mailing List <us...@struts.apache.org>
> > Sent: Friday, September 4, 2009 12:48:43 PM
> > Subject: [S2] i18n for lists/maps
> >
> > Hi,
> >
> > Normally, we use the resource bundles to store Strings like field labels,
> > error messages etc. But how about things like dropdown display values ? .
> I
> > need to i18n-ize an app that has a lot of such dropdowns and the lists
> are
> > currently referenced like
> > list="#application.dropdownmap['loanType']"/> where dropdownmap is loaded
> > into ServletContext from a properties file . that has definitions like :
> > loanType=1~Home Loan|2~Car Loan|3~Refi etc. Here, the 1,2,3 remains
> constant
> > but the display value will vary by locale.
> >
> > It'll be really neat if it's possible to maintain this list in a typical
> > resource bundle file like ApplicationResources_and be able to use
> > it from s:select tags without having to do any manual parsing. Any inputs
> > will be really helpful.
> >
> > Thanks!
>
> Hi Alex,
>
> I don't mean to advice you on adding more complexity to your project but
> Mike Baranski and I were discussing about using/getting the ResourceBundle
> from DB backend instead.  He had one working:
>
> "Here you go, this is what I did.  I don't know if it's the "best" way, but
> it works:
>
> http://mikeski.net/site/node/37
>
> Mike."
>
> I had planned on using DB backend instead solely so that anyone with the
> proper privileges via the web UI can add/change the texts.  You only need to
> provide the proper db structure and key for the texts.  If you do implement
> DB backend, IMHO, I think it will give you more flexibility for the future
> and less of the menial work ;), especially when they (your boss and/or
> client(s)) decide to use additional language.
>
> Regards,
> Tommy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] i18n for lists/maps

Posted by Tommy Pham <to...@yahoo.com>.
----- Original Message ----
> From: j alex <st...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Friday, September 4, 2009 12:48:43 PM
> Subject: [S2] i18n for lists/maps
> 
> Hi,
> 
> Normally, we use the resource bundles to store Strings like field labels,
> error messages etc. But how about things like dropdown display values ? . I
> need to i18n-ize an app that has a lot of such dropdowns and the lists are
> currently referenced like 
> list="#application.dropdownmap['loanType']"/> where dropdownmap is loaded
> into ServletContext from a properties file . that has definitions like :
> loanType=1~Home Loan|2~Car Loan|3~Refi etc. Here, the 1,2,3 remains constant
> but the display value will vary by locale.
> 
> It'll be really neat if it's possible to maintain this list in a typical
> resource bundle file like ApplicationResources_and be able to use
> it from s:select tags without having to do any manual parsing. Any inputs
> will be really helpful.
> 
> Thanks!

Hi Alex,

I don't mean to advice you on adding more complexity to your project but Mike Baranski and I were discussing about using/getting the ResourceBundle from DB backend instead.  He had one working:

"Here you go, this is what I did.  I don't know if it's the "best" way, but
it works:

http://mikeski.net/site/node/37 

Mike."

I had planned on using DB backend instead solely so that anyone with the proper privileges via the web UI can add/change the texts.  You only need to provide the proper db structure and key for the texts.  If you do implement DB backend, IMHO, I think it will give you more flexibility for the future and less of the menial work ;), especially when they (your boss and/or client(s)) decide to use additional language.

Regards,
Tommy


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org