Okay, this seemed like a useful utility action to have hanging around, so here's an example. Note that I've included a couple of lines the also update JSTL's FMT_LOCALE config variable. Also note that the action expects a form that exposes the following properties: language, country, and variant (it doesn't matter if the form's a vanilla ActionForm or a flavor of DynaActionForm).
import java.util.Locale; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.jsp.jstl.core.Config; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang.StringUtils; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; public class LocaleAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String language = StringUtils.clean(BeanUtils.getProperty(form, "language")); String country = StringUtils.clean(BeanUtils.getProperty(form, "country")); String variant = StringUtils.clean(BeanUtils.getProperty(form, "variant")); if (language.length() > 0) { Locale locale = new Locale(language, country, variant); setLocale(request, locale); HttpSession session = request.getSession(true); Config.set(session, Config.FMT_LOCALE, locale); } return mapping.findForward("success"); } } Quoting Kris Schneider <[EMAIL PROTECTED]>: > See Action.setLocale > > Quoting Philip Mark Donaghy <[EMAIL PROTECTED]>: > > > > > --- Frers Michael <[EMAIL PROTECTED]> wrote: > > > Hello > > > > > > just a simple question > > > > > > how can set the actual used local? > > > > > > i have two propertie files: > > > > > > application.properties > > > application_de.properties > > > application_en.properties > > > > > > struts takes as default application_de.properties > > > > > > how can i make it that a user can click a > > > GreatBritain flag and then the application is > > > displayed in english? > > > > You should take a look at the struts-validator webapp. > > Here is the basic code... > > > > locale = new java.util.Locale(language, country); > > > > or > > > > locale = new java.util.Locale(language, ""); > > > > and > > > > session.setAttribute(Globals.LOCALE_KEY, locale); > > > > where language is en and country is UK > > > > That should do it. > > > > Phil > > > > > > > > Thanks for any help > > > > > > Michael > > -- > Kris Schneider <mailto:[EMAIL PROTECTED]> > D.O.Tech <http://www.dotech.com/> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Kris Schneider <mailto:[EMAIL PROTECTED]> D.O.Tech <http://www.dotech.com/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]