You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rendy Tapestry <re...@gmail.com> on 2011/09/08 12:43:30 UTC

Localization Problems

Hi all,

I build an application that will support two locale, that is in_ID and en. I
am using PersistentLocale to accomplish this and as consequences all my
application url are encoded with selected locale (user set it manually
through application menu). So if my application name is xyz and in_ID locale
is choosed, my url will: localhost:8080/xyz/in_ID/
If I directly access localhost:8080/xyz/ it will go to en locale because my
request header expecting US. What suppose I do to make in_ID the default
locale if I access localhost:8080/xyz ?

Thank you,
Rendy.

Re: Localization Problems

Posted by Rendy Tapestry <re...@gmail.com>.
Thanks Christian,

In my subsequent reply that become separate thread, it was already corrected
by Thiago, still got the same result (still use US locale instead of what I
change in PersistentLocale). I give up with solution #2 and try solution #1
with success.

Thanks again Christian for your help.

Rendy.

On Tue, Sep 13, 2011 at 12:33 AM, derkoe <
tapestry.christian.koeberl@gmail.com> wrote:

>
> Rendy Tapestry wrote:
> >
> > Hi Christian,
> >
> > Thank you for taking time to help. I try to solve my problem using second
> > approach from your suggestion. Creating LocalizationDispatcher and
> > register
> > it before PageRender. I try to run my application, it seems rendering
> > wasn't
> > happened (blank page is returned).
> >
> > Here is my code snippet.
> >
> > public class LocalizationDispatcher implements Dispatcher {
> >     private final PersistentLocale persistentLocale;
> >
> >     public LocalizationDispatcher(PersistentLocale persistentLocale) {
> >         this.persistentLocale = persistentLocale;
> >     }
> >
> >     public boolean dispatch(Request request, Response response) throws
> > IOException {
> >         if (!persistentLocale.isSet()) {
> >             persistentLocale.set(new Locale("in", "ID"));
> >         }
> >
> >         return true;
> >     }
> > }
> >
>
> You have to return "false" in the Dispatcher - otherwise Tapestry will
> think
> the request has been handled  and does not continue in the chain.
>
> --
> Chris
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Localization-Problems-tp4782013p4795034.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Localization Problems

Posted by derkoe <ta...@gmail.com>.
Rendy Tapestry wrote:
> 
> Hi Christian,
> 
> Thank you for taking time to help. I try to solve my problem using second
> approach from your suggestion. Creating LocalizationDispatcher and
> register
> it before PageRender. I try to run my application, it seems rendering
> wasn't
> happened (blank page is returned).
> 
> Here is my code snippet.
> 
> public class LocalizationDispatcher implements Dispatcher {
>     private final PersistentLocale persistentLocale;
> 
>     public LocalizationDispatcher(PersistentLocale persistentLocale) {
>         this.persistentLocale = persistentLocale;
>     }
> 
>     public boolean dispatch(Request request, Response response) throws
> IOException {
>         if (!persistentLocale.isSet()) {
>             persistentLocale.set(new Locale("in", "ID"));
>         }
> 
>         return true;
>     }
> }
> 

You have to return "false" in the Dispatcher - otherwise Tapestry will think
the request has been handled  and does not continue in the chain.

-- 
Chris

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Localization-Problems-tp4782013p4795034.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Localization Problems

Posted by Rendy Tapestry <re...@gmail.com>.
Hi Christian,

Thank you for taking time to help. I try to solve my problem using second
approach from your suggestion. Creating LocalizationDispatcher and register
it before PageRender. I try to run my application, it seems rendering wasn't
happened (blank page is returned).

Here is my code snippet.

public class LocalizationDispatcher implements Dispatcher {
    private final PersistentLocale persistentLocale;

    public LocalizationDispatcher(PersistentLocale persistentLocale) {
        this.persistentLocale = persistentLocale;
    }

    public boolean dispatch(Request request, Response response) throws
IOException {
        if (!persistentLocale.isSet()) {
            persistentLocale.set(new Locale("in", "ID"));
        }

        return true;
    }
}

And register it in AppModule here.

public static void
contributeMasterDispatcher(OrderedConfiguration<Dispatcher> configuration) {
    configuration.addInstance("Localization", LocalizationDispatcher.class,
"before:PageRender");
}

What seems to wrong here ?

Thanks,
Rendy.


On Fri, Sep 9, 2011 at 12:26 AM, Christian Köberl <
tapestry.christian.koeberl@gmail.com> wrote:

> 2011-09-08 13:22, Rendy Tapestry:
>
>  Yes, I just set as you do, but it doesn't work. This is because what
>> browser
>> send through request  header is US locale. Based on tapestry mechanism
>> looking up for locale, it will search the nearest locale that is en. That
>> why ordering like that doesn't work.
>>
>> Any other idea ?
>>
>
> Tapestry's best guess is to use the browser's locale - how else to find an
> initial Locale?
>
> You could decorate or replace LocalizationSetter. ComponentEventLinkEncoder
> calls LocalizationSetter#**setLocaleFromLocaleName where you could insert
> your own code returning the default you want.
>
> Another way could be to check PersistentLocale and if not isSet() set your
> own default in a Request dispatcher (before PageRenderDispatcher).
>
> --
> Chris
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Localization Problems

Posted by Christian Köberl <ta...@gmail.com>.
2011-09-08 13:22, Rendy Tapestry:
> Yes, I just set as you do, but it doesn't work. This is because what browser
> send through request  header is US locale. Based on tapestry mechanism
> looking up for locale, it will search the nearest locale that is en. That
> why ordering like that doesn't work.
>
> Any other idea ?

Tapestry's best guess is to use the browser's locale - how else to find 
an initial Locale?

You could decorate or replace LocalizationSetter. 
ComponentEventLinkEncoder calls 
LocalizationSetter#setLocaleFromLocaleName where you could insert your 
own code returning the default you want.

Another way could be to check PersistentLocale and if not isSet() set 
your own default in a Request dispatcher (before PageRenderDispatcher).

-- 
Chris

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


Re: Localization Problems

Posted by Rendy Tapestry <re...@gmail.com>.
Yes, I just set as you do, but it doesn't work. This is because what browser
send through request  header is US locale. Based on tapestry mechanism
looking up for locale, it will search the nearest locale that is en. That
why ordering like that doesn't work.

Any other idea ?

Sorry forgot to mention, my tapestry version is 5.2.6.

Thank you,
Rendy.

On Thu, Sep 8, 2011 at 5:59 PM, Taha Hafeez <ta...@gmail.com>wrote:

> I have not used it but I think the first locale in configuration
> parameter tapestry.supported-locales(
> SymbolConstants.SUPPORTED_LOCALES) is used as the default.
>
> So "in_ID,en" will make in_ID as default.
>
> Just a guess :)
>
>
> On Thu, Sep 8, 2011 at 4:13 PM, Rendy Tapestry <re...@gmail.com>
> wrote:
> > Hi all,
> >
> > I build an application that will support two locale, that is in_ID and
> en. I
> > am using PersistentLocale to accomplish this and as consequences all my
> > application url are encoded with selected locale (user set it manually
> > through application menu). So if my application name is xyz and in_ID
> locale
> > is choosed, my url will: localhost:8080/xyz/in_ID/
> > If I directly access localhost:8080/xyz/ it will go to en locale because
> my
> > request header expecting US. What suppose I do to make in_ID the default
> > locale if I access localhost:8080/xyz ?
> >
> > Thank you,
> > Rendy.
> >
>
>
>
> --
> Regards
>
> Taha Hafeez Siddiqi (tawus)
> http://tawus.wordpress.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Localization Problems

Posted by Taha Hafeez <ta...@gmail.com>.
I have not used it but I think the first locale in configuration
parameter tapestry.supported-locales(
SymbolConstants.SUPPORTED_LOCALES) is used as the default.

So "in_ID,en" will make in_ID as default.

Just a guess :)


On Thu, Sep 8, 2011 at 4:13 PM, Rendy Tapestry <re...@gmail.com> wrote:
> Hi all,
>
> I build an application that will support two locale, that is in_ID and en. I
> am using PersistentLocale to accomplish this and as consequences all my
> application url are encoded with selected locale (user set it manually
> through application menu). So if my application name is xyz and in_ID locale
> is choosed, my url will: localhost:8080/xyz/in_ID/
> If I directly access localhost:8080/xyz/ it will go to en locale because my
> request header expecting US. What suppose I do to make in_ID the default
> locale if I access localhost:8080/xyz ?
>
> Thank you,
> Rendy.
>



-- 
Regards

Taha Hafeez Siddiqi (tawus)
http://tawus.wordpress.com

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