Re: [Webwork-user] I18n and more
Brought to you by:
baldree,
rickardoberg
From: Maurice C . P. <Ma...@Vi...> - 2000-12-06 12:27:30
|
Hey, * Rickard Öberg (ri...@jb...) wrote: > Hi! > > "Maurice C . Parker" wrote: > > Since we are on the subject of i18n, I have notice that I am hard coding a lot of English error messages in my actions. Of course I could use a resource bundle, but I was thinking that doing an i18n error message lookup by default in ActionSupport and ActionFormSupport would be more convenient. > > Hm, well, I don't think this needs to be in the base support classes. > It's very simple to do in an application base class, or in each action > if you want to. > > protected ResourceBundle getMessages() > { > return ResourceBundle.getBundle("myaction", getLocale()); > } > > public object execute() > { > // Validation > if (.. error detected ..) > { > addErrorMessage(messages.getString("error.occurred")); // Get > localized message > } > } > > Or what did you have in mind? > Right, after thinking it over some more I came to the same conclusion. My original line of thinking had been that since it was so trivial to implement i18n error messages in the Support classes, maybe it should be the default behavior for Webwork error messages. Then I slept on it and realized that this may be a little confusing to a newer programmer trying to learn Webwork. "How do these crazy error messages work? I don't need i18n for my corporate intranet application!" A better solution would be to include subclasses of the Support classes in the i18n example, just to show i18n error messages being used. Then put a note in the Best Practices that it is often desirable to create a personalized version of the Support classes for more feature rich applications. Later, Maurice |