> -----Original Message----- > From: Woodchuck [mailto:[EMAIL PROTECTED] > Sent: Tuesday, December 21, 2004 10:43 AM > To: Struts Users Mailing List > Subject: RE: ActionMessage replacement "keys" ? > > > hi Jim! > > but i think most of the time when there needs to be a replacement > value, that value is in the form of a noun (at least that's how my > messages are). so given a message with replacement placeholders, > wouldn't the only issue be the placement (position) of these > placeholders within the context of the localized message? > > if the replacement values are for other things that are not nouns then > it would be much harder to object-orientify (new word!) messages. > > but i also see your point. just having one unique message for each > unique situation is simple and does the job. the only negative thing > is that it takes up more memory when the message bundle is cached in > application scope since there will be a lot of duplication in the > bundle. > > i was hoping i could clean things up. for example, instead of this: > > error.invalid.first.name=Invalid first name > error.invalid.last.name=Invalid last name > error.invalid.middle.name=Invalid middle name > error.invalid.address=Invalid address > error.invalid.zip.code=Invalid zip code > > i could get this: > > error.generic.invalid=Invalid {0}
In this particular case, you're probabaly okay. I was thinking you meant something more complicated, such as an entire paragraph of boilerplate etc. Complex error mesaages though.... > > first.name=first name > last.name=last name > middle.name=middle name > address=address > zip.code=zip code > > and hoping i could do something like this: > > new ActionMessage("error.generic.invalid", "first.name"); > > doesn't it seem odd that ActionMessage doesn't already have > the ability > to use other keys as replacement values... i can't think of > any reason > for this other than it was simply forgotten Not really. No one else has had this itch strong enough to scratch it. > > > "Somebody set up us the bomb! All your base are belong to us!" now > that would be a major translation problem. no argument here. :D The problem isn't translating bad English.... the problem here is that this is probably a direct translation of the original language. > > woodchuck > > > > --- Jim Barrows <[EMAIL PROTECTED]> wrote: > > > > > > > > -----Original Message----- > > > From: Woodchuck [mailto:[EMAIL PROTECTED] > > > Sent: Tuesday, December 21, 2004 8:23 AM > > > To: struts > > > Subject: ActionMessage replacement "keys" ? > > > > > > > > > hihi all, > > > > > > is everyone rolling their own helper function to use other > > > message keys > > > as replacement values when creating ActionMessage or ActionError > > > objects? > > > > > > i'm wondering if there's a better way to do this other than > > > getting the > > > MessageResources object and calling the getMessage() function then > > > putting the results into an object array and then passing this to > > the > > > ActionMessage constructor... > > > > > > can/will this functionality be added to the ActionMessage > > > object in the > > > future? > > > > If you're talking about building a message using other keys, no. I > > generally find that I am better off using a seperate key for such > > situations. The problem I run usually into is one of syntax, > > especially with other languages. Breaking things up like that can > > make it harder to structure a well formed sentence. Since one of my > > pet peeves is messages that are not grammatically correct, I avoid > > this at all costs. > > > > Consider an English message translated into say German. IIRC there > > is a joke about a German teacher who ends every class with 5 minutes > > of verbs. Apparently German verb structure is different then > > English, so how would fit that structure into your messages? Or > > Navajo, which is completely different from any other language? > > > > Such flexibitlity in your messages might be nice from a programming > > standpoint, but could be a major pain when translating into foreign > > languages. > > > > So, my answer to your question is that I don't use message resource > > keys as arguments to my messages. In such cases I just use a > > different message key for each possibilty. > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > __________________________________ > Do you Yahoo!? > Read only the mail you want - Yahoo! Mail SpamGuard. > http://promotions.yahoo.com/new_mail > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]