You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Julien HENRY <he...@yahoo.fr> on 2009/08/15 00:46:23 UTC

Re : Re : Re : Re : Struts2 + I18N

I tried to edit the FAQ but I'm not allowed to do so.

http://struts.apache.org/2.x/docs/faqs.html





________________________________
De : Musachy Barroso <mu...@gmail.com>
À : Struts Users Mailing List <us...@struts.apache.org>
Envoyé le : Samedi, 15 Août 2009, 0h39mn 27s
Objet : Re: Re : Re : Re : Struts2 + I18N

This would make a good FAQ if it is not there already.

On Fri, Aug 14, 2009 at 3:25 PM, Julien HENRY<he...@yahoo.fr> wrote:
> Very, very hackish... but I like it ;)
>
> Thanks for this very good trick.
>
>
>
>
> ________________________________
> De : Chris Pratt <th...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>
> Envoyé le : Samedi, 15 Août 2009, 0h13mn 19s
> Objet : Re: Re : Re : Struts2 + I18N
>
> One trick I've used in the past is to put an empty (usually containing a
> comment saying to look in default.properties) default_en.properties file in
> the application.  Since all entries roll up to the default.properties
> anyway, if the bundle loader finds the empty file, he gets all warm and
> fuzzy and everything just seems to work.
>  (*Chris*)
>
> On Fri, Aug 14, 2009 at 3:03 PM, Musachy Barroso <mu...@gmail.com> wrote:
>
>> There is a major refactoring planned for xwork's I18n, this should
>> probably be part of it. Rene you watching this?
>>
>> musachy
>>
>> On Fri, Aug 14, 2009 at 2:16 PM, Julien HENRY<he...@yahoo.fr> wrote:
>> > After digging into Struts2 code, here is what I discovered: this bug is
>> simply caused by the normal behavior of getBundle (
>> http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader)<http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle%28java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader%29>
>> )
>> >
>> > Here is the explanation
>> >
>> > In my Struts2 application I have the following language files:
>> >
>> >
>> > default_de.properties
>> > default_fr.properties
>> > default.properties (contains EN)
>> >
>> > JVM Defaut Locale: fr_FR
>> >
>> >
>> > Scenario 1:
>> > struts.locale not set so fr_FR is the default
>> > When hitting the first action, default_fr.properties is used
>> > OK
>> >
>> > Scenario2:
>> > Now I want to switch to English so I append ?request_locale=en to the URL
>> > According to getBundle algorithm:
>> >    1) default_en.properties is looked but not found
>> >    2) default_fr.properties is found and used
>> > KO
>> >
>> > Scenario 3:
>> > struts.locale is set to en_US
>> > When hitting the first action, we are in the same case as scenario 2
>> because JVM default is still fr_FR
>> >
>> > The issue lay in LocalizedTextUtil.findResourceBundle(String
>> > bundleName, Locale locale) because here we only know that the user
>> > wants the given locale but we have no idea of what is the fallback
>> > locale.
>> >
>> > Proposed solutions:
>> >
>> > 1) default.properties should always match JVM language. Because an
>> application may be developped for several country it means forcing default
>> JVM with -Duser.language=XX. But this is not a good solution because the
>> same JVM may host several applications with possibly different default
>> Locale.
>> >
>> > 2) Force JVM default locale on Struts startup to be equal to
>> struts.locale. The main concern is I'm not sure it will works fine with
>> multi-threading and it will have many side effects (like changing language
>> for stacktraces in the log)
>> >
>> > 3) Clean solution : have a clear separation between requested locale
>> (with potentialy a default struts.default.request.locale) and default local
>> (mean the locale that is contained in the resource bundle without
>> extension). Then use the Java 1.6 feature (I know, I know, don't shout at
>> me) ResourceBundle.Control that allow to change the fallback locale.
>> >
>> > Interesting read:
>> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5086301
>> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4303146
>> >
>> > It seems that JSF implements its own lookup algorithm. IMHO this is the
>> only solution if you don't want to use the JDK 1.6 feature
>> ResourceBundle.Control.
>> >
>> >
>> > Regards,
>> >
>> > Julien
>> >
>> >
>> >
>> >
>> > ________________________________
>> > De : "mailtolouis2020-struts@yahoo.com" <
>> mailtolouis2020-struts@yahoo.com>
>> > À : Struts Users Mailing List <us...@struts.apache.org>
>> > Envoyé le : Vendredi, 14 Août 2009, 18h12mn 52s
>> > Objet : Re: Re : Struts2 +  I18N
>> >
>> > Not long ago, someone also got similar problem:
>> >
>> >
>> http://markmail.org/message/mozukqgrnhfbq7od?q=s2+and+default+locale/language+list:org.apache.struts.users/
>> >
>> >
>> >
>> >
>> > ________________________________
>> > From: Julien HENRY <he...@yahoo.fr>
>> > To: Struts Users Mailing List <us...@struts.apache.org>
>> > Sent: Friday, August 14, 2009 4:52:28 PM
>> > Subject: Re : Struts2 +  I18N
>> >
>> > Hi,
>> >
>> > AFAIK this is the same as adding <constant name="struts.locale"
>> value="en" /> in struts.xml.
>> >
>> > BTW I tried your suggestion without much improvement.
>> >
>> > I even tried to rename default.properties in default_en.properties =>
>> still no english.
>> >
>> >
>> >
>> >
>> > ________________________________
>> > De : BALAJI CRB <BA...@spanservices.com>
>> > À : Struts Users Mailing List <us...@struts.apache.org>
>> > Envoyé le : Vendredi, 14 Août 2009, 17h47mn 37s
>> > Objet : RE: Struts2 +  I18N
>> >
>> > Hi,
>> >
>> >
>> >
>> > Use struts.locale=en   in your struts.properties file. Hope this works.
>> >
>> > Regards,
>> >
>> > Balaji C R B
>> >
>> >
>> >
>> > -----Original Message-----
>> > From: Julien HENRY [mailto:henryju@yahoo.fr]
>> > Sent: Friday, August 14, 2009 9:11 PM
>> > To: user@struts.apache.org
>> > Subject: Struts2 + I18N
>> >
>> >
>> >
>> > Hi,
>> >
>> >
>> >
>> > In my Struts2 application I have the following language files:
>> >
>> >
>> >
>> > default_de.properties
>> >
>> > default_fr.properties
>> >
>> > default.properties (contains EN)
>> >
>> >
>> >
>> > When I start my application, the application is in French (probably
>> because JVM default locale is french). Then I tried to change language by
>> appending ?request_locale=XX in the URL.
>> >
>> >
>> >
>> > Adding ?request_locale=de works fine. All texts are in German.
>> >
>> >
>> >
>> > Adding ?request_locale=en doesn't work. All texts are in French.
>> >
>> >
>> >
>> > I tried to add
>> >
>> > <constant name="struts.locale" value="en" />
>> >
>> > to struts.xml but no luck.
>> >
>> >
>> >
>> > How can I tell Struts that the default.properties file is English?
>> >
>> >
>> >
>> > Thanks,
>> >
>> >
>> >
>> > Julien
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > DISCLAIMER:
>> >
>> > This email message and all attachments are  confidential and may contain
>> information that
>> > is privileged,  confidential or exempt from  disclosure under applicable
>> law.  If you are
>> > not  the intended  recipient,  you  are notified  that any dissemination,
>> distribution or
>> > copying  of this email  is strictly prohibited. If you have received this
>> email in error,
>> > please notify us immediately by return email or to
>> mailadmin@spanservices.com and destroy
>> > the original message.
>> >
>> > Opinions, conclusions, and other  information in  this message that  do
>> not relate to the
>> > official business of SPAN, shall be understood to be neither given nor
>> endorsed by SPAN.
>> >
>> >
>> >
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


      

RE: Re : Re : Re : Re : Struts2 + I18N

Posted by Martin Gainty <mg...@hotmail.com>.
nm: 
a long hot summer day is thankfully over

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Fri, 14 Aug 2009 16:37:40 -0700
> Subject: Re: Re : Re : Re : Re : Struts2 + I18N
> From: musachy@gmail.com
> To: user@struts.apache.org
> 
> On Fri, Aug 14, 2009 at 4:31 PM, Martin Gainty<mg...@hotmail.com> wrote:
> > sounds expensive..will they take cc?
> 
> What in Apollo's holy name are you talking about?
> 
> musachy
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Get free photo software from Windows Live
http://www.windowslive.com/online/photos?ocid=PID23393::T:WLMTAGL:ON:WL:en-US:SI_PH_software:082009

Re: Re : Re : Re : Re : Struts2 + I18N

Posted by Musachy Barroso <mu...@gmail.com>.
On Fri, Aug 14, 2009 at 4:31 PM, Martin Gainty<mg...@hotmail.com> wrote:
> sounds expensive..will they take cc?

What in Apollo's holy name are you talking about?

musachy
-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Re : Re : Re : Re : Struts2 + I18N

Posted by Martin Gainty <mg...@hotmail.com>.
sounds expensive..will they take cc?

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Fri, 14 Aug 2009 15:58:05 -0700
> Subject: Re: Re : Re : Re : Re : Struts2 + I18N
> From: musachy@gmail.com
> To: user@struts.apache.org
> 
> You need to fax an iCLA: http://www.apache.org/licenses/icla.txt and
> then someone can grant you access to the wiki.
> 
> musachy
> 
> On Fri, Aug 14, 2009 at 3:46 PM, Julien HENRY<he...@yahoo.fr> wrote:
> > I tried to edit the FAQ but I'm not allowed to do so.
> >
> > http://struts.apache.org/2.x/docs/faqs.html
> >
> >
> >
> >
> >
> > ________________________________
> > De : Musachy Barroso <mu...@gmail.com>
> > À : Struts Users Mailing List <us...@struts.apache.org>
> > Envoyé le : Samedi, 15 Août 2009, 0h39mn 27s
> > Objet : Re: Re : Re : Re : Struts2 + I18N
> >
> > This would make a good FAQ if it is not there already.
> >
> > On Fri, Aug 14, 2009 at 3:25 PM, Julien HENRY<he...@yahoo.fr> wrote:
> >> Very, very hackish... but I like it ;)
> >>
> >> Thanks for this very good trick.
> >>
> >>
> >>
> >>
> >> ________________________________
> >> De : Chris Pratt <th...@gmail.com>
> >> À : Struts Users Mailing List <us...@struts.apache.org>
> >> Envoyé le : Samedi, 15 Août 2009, 0h13mn 19s
> >> Objet : Re: Re : Re : Struts2 + I18N
> >>
> >> One trick I've used in the past is to put an empty (usually containing a
> >> comment saying to look in default.properties) default_en.properties file in
> >> the application.  Since all entries roll up to the default.properties
> >> anyway, if the bundle loader finds the empty file, he gets all warm and
> >> fuzzy and everything just seems to work.
> >>  (*Chris*)
> >>
> >> On Fri, Aug 14, 2009 at 3:03 PM, Musachy Barroso <mu...@gmail.com> wrote:
> >>
> >>> There is a major refactoring planned for xwork's I18n, this should
> >>> probably be part of it. Rene you watching this?
> >>>
> >>> musachy
> >>>
> >>> On Fri, Aug 14, 2009 at 2:16 PM, Julien HENRY<he...@yahoo.fr> wrote:
> >>> > After digging into Struts2 code, here is what I discovered: this bug is
> >>> simply caused by the normal behavior of getBundle (
> >>> http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader)<http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle%28java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader%29>
> >>> )
> >>> >
> >>> > Here is the explanation
> >>> >
> >>> > In my Struts2 application I have the following language files:
> >>> >
> >>> >
> >>> > default_de.properties
> >>> > default_fr.properties
> >>> > default.properties (contains EN)
> >>> >
> >>> > JVM Defaut Locale: fr_FR
> >>> >
> >>> >
> >>> > Scenario 1:
> >>> > struts.locale not set so fr_FR is the default
> >>> > When hitting the first action, default_fr.properties is used
> >>> > OK
> >>> >
> >>> > Scenario2:
> >>> > Now I want to switch to English so I append ?request_locale=en to the URL
> >>> > According to getBundle algorithm:
> >>> >    1) default_en.properties is looked but not found
> >>> >    2) default_fr.properties is found and used
> >>> > KO
> >>> >
> >>> > Scenario 3:
> >>> > struts.locale is set to en_US
> >>> > When hitting the first action, we are in the same case as scenario 2
> >>> because JVM default is still fr_FR
> >>> >
> >>> > The issue lay in LocalizedTextUtil.findResourceBundle(String
> >>> > bundleName, Locale locale) because here we only know that the user
> >>> > wants the given locale but we have no idea of what is the fallback
> >>> > locale.
> >>> >
> >>> > Proposed solutions:
> >>> >
> >>> > 1) default.properties should always match JVM language. Because an
> >>> application may be developped for several country it means forcing default
> >>> JVM with -Duser.language=XX. But this is not a good solution because the
> >>> same JVM may host several applications with possibly different default
> >>> Locale.
> >>> >
> >>> > 2) Force JVM default locale on Struts startup to be equal to
> >>> struts.locale. The main concern is I'm not sure it will works fine with
> >>> multi-threading and it will have many side effects (like changing language
> >>> for stacktraces in the log)
> >>> >
> >>> > 3) Clean solution : have a clear separation between requested locale
> >>> (with potentialy a default struts.default.request.locale) and default local
> >>> (mean the locale that is contained in the resource bundle without
> >>> extension). Then use the Java 1.6 feature (I know, I know, don't shout at
> >>> me) ResourceBundle.Control that allow to change the fallback locale.
> >>> >
> >>> > Interesting read:
> >>> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5086301
> >>> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4303146
> >>> >
> >>> > It seems that JSF implements its own lookup algorithm. IMHO this is the
> >>> only solution if you don't want to use the JDK 1.6 feature
> >>> ResourceBundle.Control.
> >>> >
> >>> >
> >>> > Regards,
> >>> >
> >>> > Julien
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > ________________________________
> >>> > De : "mailtolouis2020-struts@yahoo.com" <
> >>> mailtolouis2020-struts@yahoo.com>
> >>> > À : Struts Users Mailing List <us...@struts.apache.org>
> >>> > Envoyé le : Vendredi, 14 Août 2009, 18h12mn 52s
> >>> > Objet : Re: Re : Struts2 +  I18N
> >>> >
> >>> > Not long ago, someone also got similar problem:
> >>> >
> >>> >
> >>> http://markmail.org/message/mozukqgrnhfbq7od?q=s2+and+default+locale/language+list:org.apache.struts.users/
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > ________________________________
> >>> > From: Julien HENRY <he...@yahoo.fr>
> >>> > To: Struts Users Mailing List <us...@struts.apache.org>
> >>> > Sent: Friday, August 14, 2009 4:52:28 PM
> >>> > Subject: Re : Struts2 +  I18N
> >>> >
> >>> > Hi,
> >>> >
> >>> > AFAIK this is the same as adding <constant name="struts.locale"
> >>> value="en" /> in struts.xml.
> >>> >
> >>> > BTW I tried your suggestion without much improvement.
> >>> >
> >>> > I even tried to rename default.properties in default_en.properties =>
> >>> still no english.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > ________________________________
> >>> > De : BALAJI CRB <BA...@spanservices.com>
> >>> > À : Struts Users Mailing List <us...@struts.apache.org>
> >>> > Envoyé le : Vendredi, 14 Août 2009, 17h47mn 37s
> >>> > Objet : RE: Struts2 +  I18N
> >>> >
> >>> > Hi,
> >>> >
> >>> >
> >>> >
> >>> > Use struts.locale=en   in your struts.properties file. Hope this works.
> >>> >
> >>> > Regards,
> >>> >
> >>> > Balaji C R B
> >>> >
> >>> >
> >>> >
> >>> > -----Original Message-----
> >>> > From: Julien HENRY [mailto:henryju@yahoo.fr]
> >>> > Sent: Friday, August 14, 2009 9:11 PM
> >>> > To: user@struts.apache.org
> >>> > Subject: Struts2 + I18N
> >>> >
> >>> >
> >>> >
> >>> > Hi,
> >>> >
> >>> >
> >>> >
> >>> > In my Struts2 application I have the following language files:
> >>> >
> >>> >
> >>> >
> >>> > default_de.properties
> >>> >
> >>> > default_fr.properties
> >>> >
> >>> > default.properties (contains EN)
> >>> >
> >>> >
> >>> >
> >>> > When I start my application, the application is in French (probably
> >>> because JVM default locale is french). Then I tried to change language by
> >>> appending ?request_locale=XX in the URL.
> >>> >
> >>> >
> >>> >
> >>> > Adding ?request_locale=de works fine. All texts are in German.
> >>> >
> >>> >
> >>> >
> >>> > Adding ?request_locale=en doesn't work. All texts are in French.
> >>> >
> >>> >
> >>> >
> >>> > I tried to add
> >>> >
> >>> > <constant name="struts.locale" value="en" />
> >>> >
> >>> > to struts.xml but no luck.
> >>> >
> >>> >
> >>> >
> >>> > How can I tell Struts that the default.properties file is English?
> >>> >
> >>> >
> >>> >
> >>> > Thanks,
> >>> >
> >>> >
> >>> >
> >>> > Julien
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > DISCLAIMER:
> >>> >
> >>> > This email message and all attachments are  confidential and may contain
> >>> information that
> >>> > is privileged,  confidential or exempt from  disclosure under applicable
> >>> law.  If you are
> >>> > not  the intended  recipient,  you  are notified  that any dissemination,
> >>> distribution or
> >>> > copying  of this email  is strictly prohibited. If you have received this
> >>> email in error,
> >>> > please notify us immediately by return email or to
> >>> mailadmin@spanservices.com and destroy
> >>> > the original message.
> >>> >
> >>> > Opinions, conclusions, and other  information in  this message that  do
> >>> not relate to the
> >>> > official business of SPAN, shall be understood to be neither given nor
> >>> endorsed by SPAN.
> >>> >
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>
> >>
> >>
> >>
> >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Express your personality in color! Preview and select themes for Hotmail®. 
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_express:082009

Re: Re : Re : Re : Re : Struts2 + I18N

Posted by Musachy Barroso <mu...@gmail.com>.
You need to fax an iCLA: http://www.apache.org/licenses/icla.txt and
then someone can grant you access to the wiki.

musachy

On Fri, Aug 14, 2009 at 3:46 PM, Julien HENRY<he...@yahoo.fr> wrote:
> I tried to edit the FAQ but I'm not allowed to do so.
>
> http://struts.apache.org/2.x/docs/faqs.html
>
>
>
>
>
> ________________________________
> De : Musachy Barroso <mu...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>
> Envoyé le : Samedi, 15 Août 2009, 0h39mn 27s
> Objet : Re: Re : Re : Re : Struts2 + I18N
>
> This would make a good FAQ if it is not there already.
>
> On Fri, Aug 14, 2009 at 3:25 PM, Julien HENRY<he...@yahoo.fr> wrote:
>> Very, very hackish... but I like it ;)
>>
>> Thanks for this very good trick.
>>
>>
>>
>>
>> ________________________________
>> De : Chris Pratt <th...@gmail.com>
>> À : Struts Users Mailing List <us...@struts.apache.org>
>> Envoyé le : Samedi, 15 Août 2009, 0h13mn 19s
>> Objet : Re: Re : Re : Struts2 + I18N
>>
>> One trick I've used in the past is to put an empty (usually containing a
>> comment saying to look in default.properties) default_en.properties file in
>> the application.  Since all entries roll up to the default.properties
>> anyway, if the bundle loader finds the empty file, he gets all warm and
>> fuzzy and everything just seems to work.
>>  (*Chris*)
>>
>> On Fri, Aug 14, 2009 at 3:03 PM, Musachy Barroso <mu...@gmail.com> wrote:
>>
>>> There is a major refactoring planned for xwork's I18n, this should
>>> probably be part of it. Rene you watching this?
>>>
>>> musachy
>>>
>>> On Fri, Aug 14, 2009 at 2:16 PM, Julien HENRY<he...@yahoo.fr> wrote:
>>> > After digging into Struts2 code, here is what I discovered: this bug is
>>> simply caused by the normal behavior of getBundle (
>>> http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader)<http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle%28java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader%29>
>>> )
>>> >
>>> > Here is the explanation
>>> >
>>> > In my Struts2 application I have the following language files:
>>> >
>>> >
>>> > default_de.properties
>>> > default_fr.properties
>>> > default.properties (contains EN)
>>> >
>>> > JVM Defaut Locale: fr_FR
>>> >
>>> >
>>> > Scenario 1:
>>> > struts.locale not set so fr_FR is the default
>>> > When hitting the first action, default_fr.properties is used
>>> > OK
>>> >
>>> > Scenario2:
>>> > Now I want to switch to English so I append ?request_locale=en to the URL
>>> > According to getBundle algorithm:
>>> >    1) default_en.properties is looked but not found
>>> >    2) default_fr.properties is found and used
>>> > KO
>>> >
>>> > Scenario 3:
>>> > struts.locale is set to en_US
>>> > When hitting the first action, we are in the same case as scenario 2
>>> because JVM default is still fr_FR
>>> >
>>> > The issue lay in LocalizedTextUtil.findResourceBundle(String
>>> > bundleName, Locale locale) because here we only know that the user
>>> > wants the given locale but we have no idea of what is the fallback
>>> > locale.
>>> >
>>> > Proposed solutions:
>>> >
>>> > 1) default.properties should always match JVM language. Because an
>>> application may be developped for several country it means forcing default
>>> JVM with -Duser.language=XX. But this is not a good solution because the
>>> same JVM may host several applications with possibly different default
>>> Locale.
>>> >
>>> > 2) Force JVM default locale on Struts startup to be equal to
>>> struts.locale. The main concern is I'm not sure it will works fine with
>>> multi-threading and it will have many side effects (like changing language
>>> for stacktraces in the log)
>>> >
>>> > 3) Clean solution : have a clear separation between requested locale
>>> (with potentialy a default struts.default.request.locale) and default local
>>> (mean the locale that is contained in the resource bundle without
>>> extension). Then use the Java 1.6 feature (I know, I know, don't shout at
>>> me) ResourceBundle.Control that allow to change the fallback locale.
>>> >
>>> > Interesting read:
>>> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5086301
>>> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4303146
>>> >
>>> > It seems that JSF implements its own lookup algorithm. IMHO this is the
>>> only solution if you don't want to use the JDK 1.6 feature
>>> ResourceBundle.Control.
>>> >
>>> >
>>> > Regards,
>>> >
>>> > Julien
>>> >
>>> >
>>> >
>>> >
>>> > ________________________________
>>> > De : "mailtolouis2020-struts@yahoo.com" <
>>> mailtolouis2020-struts@yahoo.com>
>>> > À : Struts Users Mailing List <us...@struts.apache.org>
>>> > Envoyé le : Vendredi, 14 Août 2009, 18h12mn 52s
>>> > Objet : Re: Re : Struts2 +  I18N
>>> >
>>> > Not long ago, someone also got similar problem:
>>> >
>>> >
>>> http://markmail.org/message/mozukqgrnhfbq7od?q=s2+and+default+locale/language+list:org.apache.struts.users/
>>> >
>>> >
>>> >
>>> >
>>> > ________________________________
>>> > From: Julien HENRY <he...@yahoo.fr>
>>> > To: Struts Users Mailing List <us...@struts.apache.org>
>>> > Sent: Friday, August 14, 2009 4:52:28 PM
>>> > Subject: Re : Struts2 +  I18N
>>> >
>>> > Hi,
>>> >
>>> > AFAIK this is the same as adding <constant name="struts.locale"
>>> value="en" /> in struts.xml.
>>> >
>>> > BTW I tried your suggestion without much improvement.
>>> >
>>> > I even tried to rename default.properties in default_en.properties =>
>>> still no english.
>>> >
>>> >
>>> >
>>> >
>>> > ________________________________
>>> > De : BALAJI CRB <BA...@spanservices.com>
>>> > À : Struts Users Mailing List <us...@struts.apache.org>
>>> > Envoyé le : Vendredi, 14 Août 2009, 17h47mn 37s
>>> > Objet : RE: Struts2 +  I18N
>>> >
>>> > Hi,
>>> >
>>> >
>>> >
>>> > Use struts.locale=en   in your struts.properties file. Hope this works.
>>> >
>>> > Regards,
>>> >
>>> > Balaji C R B
>>> >
>>> >
>>> >
>>> > -----Original Message-----
>>> > From: Julien HENRY [mailto:henryju@yahoo.fr]
>>> > Sent: Friday, August 14, 2009 9:11 PM
>>> > To: user@struts.apache.org
>>> > Subject: Struts2 + I18N
>>> >
>>> >
>>> >
>>> > Hi,
>>> >
>>> >
>>> >
>>> > In my Struts2 application I have the following language files:
>>> >
>>> >
>>> >
>>> > default_de.properties
>>> >
>>> > default_fr.properties
>>> >
>>> > default.properties (contains EN)
>>> >
>>> >
>>> >
>>> > When I start my application, the application is in French (probably
>>> because JVM default locale is french). Then I tried to change language by
>>> appending ?request_locale=XX in the URL.
>>> >
>>> >
>>> >
>>> > Adding ?request_locale=de works fine. All texts are in German.
>>> >
>>> >
>>> >
>>> > Adding ?request_locale=en doesn't work. All texts are in French.
>>> >
>>> >
>>> >
>>> > I tried to add
>>> >
>>> > <constant name="struts.locale" value="en" />
>>> >
>>> > to struts.xml but no luck.
>>> >
>>> >
>>> >
>>> > How can I tell Struts that the default.properties file is English?
>>> >
>>> >
>>> >
>>> > Thanks,
>>> >
>>> >
>>> >
>>> > Julien
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > DISCLAIMER:
>>> >
>>> > This email message and all attachments are  confidential and may contain
>>> information that
>>> > is privileged,  confidential or exempt from  disclosure under applicable
>>> law.  If you are
>>> > not  the intended  recipient,  you  are notified  that any dissemination,
>>> distribution or
>>> > copying  of this email  is strictly prohibited. If you have received this
>>> email in error,
>>> > please notify us immediately by return email or to
>>> mailadmin@spanservices.com and destroy
>>> > the original message.
>>> >
>>> > Opinions, conclusions, and other  information in  this message that  do
>>> not relate to the
>>> > official business of SPAN, shall be understood to be neither given nor
>>> endorsed by SPAN.
>>> >
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Re : Re : Re : Re : Struts2 + I18N

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
At the moment when we use execandwait we¹re finding that that the production
thread doesn¹t even start until after the delay period is over. For example
I did a simple test with the following configuration:

       <action name="view" class="viewAction" method="view">
            <interceptor-ref name="standardAuthStack"/>
            <interceptor-ref name="execAndWait">
                <param name="delay">2000</param>
                <param name="delaySleepInterval">50</param>
            </interceptor-ref>
            <result name="wait">/WEB-INF/pages/execAndWait.jsp</result>
            <result name="success">/WEB-INF/pages/View.jsp</result>
    </action>
> 
The view action checks for the existence of legacy data and if it exists
retrieves it ad appends to the current data. If no legacy data exists the
action is done in no time, but if legacy data is present it can take up to a
couple of minutes to extract and combine.

I was of the impression the above configuration would skip the
execAndWait.jsp page if the thread was done within 2000 milliseconds ­ with
a check every 50 milliseconds, but what actually happens is that the action
pauses for 2000 milliseconds and then starts the main thread, so we always
get the execandWait page. I tried increasing the delay to 10000 and the same
happens with just a 10 second delay.

I¹m hoping that I just haven¹t understood the configuration options, but I
haven¹t been able to find more detailed information.

Z.
> 
> Zoran Avtarovski wrote:
>> > For what it¹s worth, the I18n and the execandwait areas are the two areas I
>> > find that S2 falls down the most.
> 
> Do you have any specific suggestions for how execandwait should work?
> 
> -Dale
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


Re: Re : Re : Re : Re : Struts2 + I18N

Posted by Dale Newfield <da...@newfield.org>.
Zoran Avtarovski wrote:
> For what it¹s worth, the I18n and the execandwait areas are the two areas I
> find that S2 falls down the most.

Do you have any specific suggestions for how execandwait should work?

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re : Re : Re : Re : Re : Struts2 + I18N

Posted by Julien HENRY <he...@yahoo.fr>.
Hi Zoran,

Thank you for your suggestion but I have finally managed to have eveything working with only the trick of adding an empty file for the defaut language.
I also have the language selected according to user browser settings. The only issue is that the browser locale is stored in the session so any change to browser preferred language will only be taken into account after session expiration.
I've opened a bug with a patch: http://jira.opensymphony.com/browse/XW-714

Regards,

Julien




________________________________
De : Zoran Avtarovski <zo...@sparecreative.com>
À : Struts Users Mailing List <us...@struts.apache.org>; Julien HENRY <he...@yahoo.fr>
Envoyé le : Dimanche, 16 Août 2009, 12h33mn 25s
Objet : Re: Re : Re : Re : Re : Struts2 + I18N

Hi Julien,

I¹m not sure of it¹s too late for you, but what we did was cheat and added a
simple interceptor to the stack which set the default struts locale to
whatever you need. It was trivial piece of code and then everything worked
as expected.

For what it¹s worth, the I18n and the execandwait areas are the two areas I
find that S2 falls down the most. And what I hate even more is that we have
a new young guy on the team and every time he comes across one of hacks
we¹ve implemented I have to listen to Stripes this, and Stripes that or
Wicket this and Wicket that for the next 2 hours.

Z.



      

Re: Re : Re : Re : Re : Struts2 + I18N

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Hi Julien,

I¹m not sure of it¹s too late for you, but what we did was cheat and added a
simple interceptor to the stack which set the default struts locale to
whatever you need. It was trivial piece of code and then everything worked
as expected.

For what it¹s worth, the I18n and the execandwait areas are the two areas I
find that S2 falls down the most. And what I hate even more is that we have
a new young guy on the team and every time he comes across one of hacks
we¹ve implemented I have to listen to Stripes this, and Stripes that or
Wicket this and Wicket that for the next 2 hours.

Z.