Re: Changing to default localization without extension for the language

2013-12-17 Thread Magnus Kvalheim
Yes, decorating didn't seem possible - so have (for now) copied and
overridden PersistentLocaleImpl to allow null.

It is part of a requirement to always force locale through uri, except for
english which is on unlocalized. So need to clear persistentlocale when
switching to english.

Locale switch also set's cookie, so preferred locale is
remembered(redirect).
Approach is similar to how aws locale resolution works,
http://aws.amazon.com/ .

Have also replaced and overridden PageRender/- and
ComponentEventDispatchers to insert locale resolution logic in between
decoding of request parameters and it's delegation to request handler.
Seems to work, but let me know if someone can think of a more elegant
solution.

/magnus

On Tue, Dec 17, 2013 at 9:03 PM, Lance Java wrote:

> I'm surprised that PersistentLocale does not have the ability to clear the
> value once it's set. Looking at PersistentLocaleImpl it doesn't allow
> setting to null.
>
> Perhaps you could override / decorate PersistentLocale to support clearing
> the value (by setting null).
>
> If decorating, you'll likely require a PerThreadValue. If overriding,
> you'll likely copy / paste / tweak PersistentLocaleImpl.
>


Re: Changing to default localization without extension for the language

2013-12-17 Thread Lance Java
I'm surprised that PersistentLocale does not have the ability to clear the
value once it's set. Looking at PersistentLocaleImpl it doesn't allow
setting to null.

Perhaps you could override / decorate PersistentLocale to support clearing
the value (by setting null).

If decorating, you'll likely require a PerThreadValue. If overriding,
you'll likely copy / paste / tweak PersistentLocaleImpl.


Re: Changing to default localization without extension for the language

2013-12-17 Thread Thiago H de Paula Figueiredo

Or file a JIRA. A beta has just came out, so a new release isn't far. :)

On Tue, 17 Dec 2013 18:03:04 -0200, Lance Java   
wrote:


I'm surprised that PersistentLocale does not have the ability to clear  
the

value once it's set. Looking at PersistentLocaleImpl it doesn't allow
setting to null.

Perhaps you could override / decorate PersistentLocale to support  
clearing

the value (by setting null).

If decorating, you'll likely require a PerThreadValue. If overriding,
you'll likely copy / paste / tweak PersistentLocaleImpl.



--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Changing to default localization without extension for the language

2013-12-17 Thread Magnus Kvalheim
Hi Geoff.

A bit of an old thread now, but am also looking for a way to clear/reset
persistent locale.

Did you/anyone come up with a solution?

/magnus


On Sat, Nov 24, 2012 at 3:57 AM, Geoff Callender <
geoff.callender.jumpst...@gmail.com> wrote:

> Once I have gone to a specific locale I can't get back to the default
> locale in a way that leaves locale out of the URL.
>
> eg. from
> http://localhost:8080/myapp/mypage
> to
> http://localhost:8080/myapp/en_GB/mypage
> and back to
> http://localhost:8080/myapp/mypage
>
> I have tried LocalizationSetter#setLocaleFromLocaleName("") but the locale
> won't change because it isn't supported.
> So I tried adding "" to the SUPPORTED_LOCALES, and that gave me an invalid
> URL:
>
> http://localhost:8080/myapp//mypage
>
> Exactly the same effect using Locale.ROOT, because Locale.ROOT.toString()
> is "" and Locale.ROOT.getDisplayName() is "".
>
> The source of the problem seems to be that locale starts off as null in
> ThreadLocaleImpl and PersistentLocaleImpl but it's not possible to set it
> back to null.
>
> What have I missed?
>
> On 20/11/2012, at 12:55 AM, Ivan Khalopik wrote:
>
> > I don't understand your question.
> > But if you change locale using PersistentLocale service it will be
> > persisted in URL and be changed for next page request. The new localale
> > should also be configured in "tapestry.supported-locales" symbol.
> > If you want to chnge locale just for this request you can use
> > ThreadLocale#setLocale(...) method.
> > If you need both variants with safety and advantage of finding the
> closest
> > supported locale use LocalizationSetter#setLocaleFromLocaleName("en")
> >
> > All message catalogs will be accessed by tapestry with right choose. Just
> > use .properties for default locale, _ro.properties to override properties
> > for ro locale, _en.properties for en locale.
> > If you want to change locale to default (not ro) use Locale.ROOT constant
> > for java 6, and new Locale("") for older versions.
> >
> > On Mon, Nov 19, 2012 at 3:10 PM, o3005659  wrote:
> >
> >> I have made localization ro and en. Ro is by default, however I didn't
> >> extend
> >> my property files with_ro extension, but I simply put
> >> thisispropertyfile.properties. Now I have implemented for English
> >>
> >>  public String onActionFromGoEnglish()
> >>{
> >>persistentLocale.set(new Locale("en"));
> >>return null;
> >>}
> >>
> >> however, I don't know how to access property files that have no _ro
> >> extension in example when user switches from en to ro. What to points my
> >> persistenLocale then?
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tapestry.1045711.n5.nabble.com/Changing-to-default-localization-without-extension-for-the-language-tp5718092.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > BR
> > Ivan
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Changing to default localization without extension for the language

2012-11-23 Thread Geoff Callender
Once I have gone to a specific locale I can't get back to the default locale in 
a way that leaves locale out of the URL.

eg. from 
http://localhost:8080/myapp/mypage
to 
http://localhost:8080/myapp/en_GB/mypage
and back to
http://localhost:8080/myapp/mypage

I have tried LocalizationSetter#setLocaleFromLocaleName("") but the locale 
won't change because it isn't supported.
So I tried adding "" to the SUPPORTED_LOCALES, and that gave me an invalid URL:

http://localhost:8080/myapp//mypage

Exactly the same effect using Locale.ROOT, because Locale.ROOT.toString() is "" 
and Locale.ROOT.getDisplayName() is "".

The source of the problem seems to be that locale starts off as null in 
ThreadLocaleImpl and PersistentLocaleImpl but it's not possible to set it back 
to null.

What have I missed?

On 20/11/2012, at 12:55 AM, Ivan Khalopik wrote:

> I don't understand your question.
> But if you change locale using PersistentLocale service it will be
> persisted in URL and be changed for next page request. The new localale
> should also be configured in "tapestry.supported-locales" symbol.
> If you want to chnge locale just for this request you can use
> ThreadLocale#setLocale(...) method.
> If you need both variants with safety and advantage of finding the closest
> supported locale use LocalizationSetter#setLocaleFromLocaleName("en")
> 
> All message catalogs will be accessed by tapestry with right choose. Just
> use .properties for default locale, _ro.properties to override properties
> for ro locale, _en.properties for en locale.
> If you want to change locale to default (not ro) use Locale.ROOT constant
> for java 6, and new Locale("") for older versions.
> 
> On Mon, Nov 19, 2012 at 3:10 PM, o3005659  wrote:
> 
>> I have made localization ro and en. Ro is by default, however I didn't
>> extend
>> my property files with_ro extension, but I simply put
>> thisispropertyfile.properties. Now I have implemented for English
>> 
>>  public String onActionFromGoEnglish()
>>{
>>persistentLocale.set(new Locale("en"));
>>return null;
>>}
>> 
>> however, I don't know how to access property files that have no _ro
>> extension in example when user switches from en to ro. What to points my
>> persistenLocale then?
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Changing-to-default-localization-without-extension-for-the-language-tp5718092.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
>> 
> 
> 
> -- 
> BR
> Ivan


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Changing to default localization without extension for the language

2012-11-21 Thread o3005659
Thanks, Sody! :)



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Changing-to-default-localization-without-extension-for-the-language-tp5718092p5718175.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Changing to default localization without extension for the language

2012-11-19 Thread Ivan Khalopik
I don't understand your question.
But if you change locale using PersistentLocale service it will be
persisted in URL and be changed for next page request. The new localale
should also be configured in "tapestry.supported-locales" symbol.
If you want to chnge locale just for this request you can use
ThreadLocale#setLocale(...) method.
If you need both variants with safety and advantage of finding the closest
supported locale use LocalizationSetter#setLocaleFromLocaleName("en")

All message catalogs will be accessed by tapestry with right choose. Just
use .properties for default locale, _ro.properties to override properties
for ro locale, _en.properties for en locale.
If you want to change locale to default (not ro) use Locale.ROOT constant
for java 6, and new Locale("") for older versions.

On Mon, Nov 19, 2012 at 3:10 PM, o3005659  wrote:

> I have made localization ro and en. Ro is by default, however I didn't
> extend
> my property files with_ro extension, but I simply put
> thisispropertyfile.properties. Now I have implemented for English
>
>   public String onActionFromGoEnglish()
> {
> persistentLocale.set(new Locale("en"));
> return null;
> }
>
> however, I don't know how to access property files that have no _ro
> extension in example when user switches from en to ro. What to points my
> persistenLocale then?
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Changing-to-default-localization-without-extension-for-the-language-tp5718092.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
BR
Ivan