AW: How to test only for the language-code but not for the country?

2001-09-13 Thread Friedli Beat [UFA AG Her]
Title: How to test only for the language-code but not for the country?



Tanks 
for your answer. Do you hava an idea how i could pack this in a Tag? Or even 
better if there allready exists a Tag in struts that allows to include a 
HTML-text only if a certain language is chosen?

Beat Friedli 
-- 


  
  i 
  faced a similar problem and i override the processLocale method of 
  ActionServlet as follows...
  
  protected void processLocale(HttpServletRequest 
  request) {
  
  // Validate that we need to create a 
  Localeif 
  (!locale)return; 
  // Service not requestedHttpSession session = 
  request.getSession();if 
  (session.getAttribute(Action.LOCALE_KEY) != 
  null)return; 
  // Locale object is already present
  
  // Use the Locale returned by the servlet 
  container (if any)Locale locale = 
  request.getLocale();if (locale != null) 
  {if 
  (locale.getLanguage().equals("en"))locale = new 
  Locale("en","US");
  
  if 
  (locale.getLanguage().equals("nl"))locale = new 
  Locale("nl","NL");
  
  if 
  (!(locale.getLanguage().equals("en") || 
  locale.getLanguage().equals("nl")))locale = new 
  Locale("nl","NL");session.setAttribute(Action.LOCALE_KEY, 
  locale);}else{locale 
  = new 
  Locale("nl","NL");session.setAttribute(Action.LOCALE_KEY, 
  locale);}}
  
  

I want to test the Accept-Language and show a french message 
if the user speaks french. 
But the following code doesn't take care of the 
Accept-Language fr-ch. 
logic:equal value="fr" 
header="Accept-Language"  Welcome 
french /logic:equal 
And this code doesn't take care of the Accept-Language 
fr-ch. 
logic:equal value="fr-ch" 
header="Accept-Language"  Welcome 
french /logic:equal 
Do I have to write my own tag? Has anybody allready an 
apropriate tag? 
thanks 
Beat Friedli 


Re: How to test only for the language-code but not for the country?

2001-09-12 Thread Gregor Rayman
Title: How to test only for the language-code but not for the country?



Use bean:message for this purpose. Not 
logic:equal.

  - Original Message - 
  From: 
  Friedli Beat 
  [UFA AG Her] 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Wednesday, September 12, 2001 11:22 
  AM
  Subject: How to test only for the 
  language-code but not for the country?
  
  I want to test the Accept-Language and show a french message 
  if the user speaks french. 
  But the following code doesn't take care of the 
  Accept-Language fr-ch. 
  logic:equal value="fr" header="Accept-Language" 
   Welcome french /logic:equal 
  And this code doesn't take care of the Accept-Language 
  fr-ch. 
  logic:equal value="fr-ch" 
  header="Accept-Language"  Welcome 
  french /logic:equal 
  Do I have to write my own tag? Has anybody allready an 
  apropriate tag? 
  thanks 
  Beat Friedli 


RE: How to test only for the language-code but not for the country?

2001-09-12 Thread Satyen . Chikane
Title: How to test only for the language-code but not for the country?



i 
faced a similar problem and i override the processLocale method of ActionServlet 
as follows...

protected void processLocale(HttpServletRequest 
request) {

// Validate that we need to create a 
Localeif 
(!locale)return; 
// Service not requestedHttpSession session = 
request.getSession();if (session.getAttribute(Action.LOCALE_KEY) 
!= 
null)return; 
// Locale object is already present

// Use the Locale returned by the servlet 
container (if any)Locale locale = 
request.getLocale();if (locale != null) 
{if 
(locale.getLanguage().equals("en"))locale = new 
Locale("en","US");

if 
(locale.getLanguage().equals("nl"))locale = new 
Locale("nl","NL");

if 
(!(locale.getLanguage().equals("en") || 
locale.getLanguage().equals("nl")))locale = new 
Locale("nl","NL");session.setAttribute(Action.LOCALE_KEY, 
locale);}else{locale 
= new 
Locale("nl","NL");session.setAttribute(Action.LOCALE_KEY, 
locale);}}


  -Original Message-From: Friedli Beat [UFA AG Her] 
  [mailto:[EMAIL PROTECTED]]Sent: Wednesday, September 12, 2001 
  10:22 AMTo: '[EMAIL PROTECTED]'Subject: How 
  to test only for the language-code but not for the 
  country?
  I want to test the Accept-Language and show a french message 
  if the user speaks french. 
  But the following code doesn't take care of the 
  Accept-Language fr-ch. 
  logic:equal value="fr" header="Accept-Language" 
   Welcome french /logic:equal 
  And this code doesn't take care of the Accept-Language 
  fr-ch. 
  logic:equal value="fr-ch" 
  header="Accept-Language"  Welcome 
  french /logic:equal 
  Do I have to write my own tag? Has anybody allready an 
  apropriate tag? 
  thanks 
  Beat Friedli 

--
The information in this Internet email is confidential and may be 
legally privileged. It is intended solely for the addressee. Access 
to this Internet email by anyone else is unauthorised.

If you are not the intended recipient, any disclosure, copying, distribution
or any action taken or omitted to be taken in reliance on it, is prohibited
and may be unlawful. When addressed to our clients any opinions or advice
contained in this Internet email are subject to the terms and conditions
expressed in any applicable governing ING Barings' terms of business or
client engagement letter.

Visit us at www.ingbarings.com

--



AW: How to test only for the language-code but not for the country?

2001-09-12 Thread Friedli Beat [UFA AG Her]
Title: How to test only for the language-code but not for the country?



bean:message sounds good to me but I have 
a whole page of just HTML to include an I don't want to put it in my 
ressource-file
I would need a Tag 
like this:

bean:message 
language="fr" 
 
.
 
.
 
Here would stand a whole user-manual of pure HTML with many 
lines
 
.
 
.
 
.
/bean:message 

Is this possible?


Thanks

Beat 
Friedli 
-- 


  -Ursprüngliche Nachricht-Von: Gregor Rayman 
  [mailto:[EMAIL PROTECTED]]Gesendet: Mittwoch, 12. September 2001 
  12:43An: [EMAIL PROTECTED]Betreff: Re: How 
  to test only for the language-code but not for the 
  country?
  Use bean:message for this purpose. Not 
  logic:equal.
  
- Original Message - 
From: 
Friedli Beat 
[UFA AG Her] 
To: '[EMAIL PROTECTED]' 

Sent: Wednesday, September 12, 2001 
11:22 AM
Subject: How to test only for the 
language-code but not for the country?

I want to test the Accept-Language and show a french message 
if the user speaks french. 
But the following code doesn't take care of the 
Accept-Language fr-ch. 
logic:equal value="fr" 
header="Accept-Language"  Welcome 
french /logic:equal 
And this code doesn't take care of the Accept-Language 
fr-ch. 
logic:equal value="fr-ch" 
header="Accept-Language"  Welcome 
french /logic:equal 
Do I have to write my own tag? Has anybody allready an 
apropriate tag? 
thanks 
Beat Friedli