Locale - how to set?

2003-10-30 Thread Frers Michael
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?

Thanks for any help

Michael

RE: Locale - how to set?

2003-10-30 Thread Paananen, Tero
 how can i make it that a user can click a GreatBritain flag 
 and then the application is displayed in english?

Locale yourLocale = fooBar();
HttpSession session = request.getSession();
session.setAttribute(Action.LOCALE_KEY, yourLocale);

-TPP

-
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Locale - how to set?

2003-10-30 Thread Philip Mark Donaghy

--- 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


__
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Locale - how to set?

2003-10-30 Thread Kris Schneider
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]



Re: Locale - how to set?

2003-10-30 Thread Kris Schneider
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]