You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by manu161184 <ma...@gmail.com> on 2009/03/14 13:38:34 UTC
I18n and nice URLs
Hi,
I want to define nice URL per language, and switch locale automatically in
relation with url.
For example :
http://www.example.com/en/home.html --> Home.java (WebPage) with english
local
http://www.example.com/fr/accueil.html --> Home.java (WebPage) with french
local
I tried :
In my WebApplication :
mountBookmarkablePage("/en/home.html",Home.class);
mountBookmarkablePage("/fr/accueil.html",Home.class);
Both urls are accessible and display home page, it's ok.
In Home.html
home page
In Home.java :
//i can get locale with request.getRequestURI() and check if url starts with
"en" or "fr" (and i think is very bad)
new BookmarkablePageLink("homeLink", Home.class); // but here, how to change
"href" with regard to locale?
thanks,
Manu
--
View this message in context: http://www.nabble.com/I18n-and-nice-URLs-tp22512232p22512232.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I18n and nice URLs
Posted by manu161184 <ma...@gmail.com>.
ahhh yes...
Sorry :blush:
thanks!
Andreas Petersson wrote:
>
>
>> matches(IRequestTarget requestTarget)
>> // but here how i can get the current locale to determine if
>> /fr/accueil
>> or /en/home matchs this mounter ???
> Session.get().getLocale().getLanguage()
>
>> decode(RequestParameters requestParameters) {
>> // but here how i can change the current locale ?
>>
> Session.get().setLocale(new Locale(#somelang#))
>
> does this work for you? this is how i use the locale.
>
> best regards,
> Andreas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/I18n-and-nice-URLs-tp22512232p22554370.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I18n and nice URLs
Posted by Andreas Petersson <an...@petersson.at>.
> matches(IRequestTarget requestTarget)
> // but here how i can get the current locale to determine if /fr/accueil
> or /en/home matchs this mounter ???
Session.get().getLocale().getLanguage()
> decode(RequestParameters requestParameters) {
> // but here how i can change the current locale ?
>
Session.get().setLocale(new Locale(#somelang#))
does this work for you? this is how i use the locale.
best regards,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I18n and nice URLs
Posted by manu161184 <ma...@gmail.com>.
Hi,
I have been try to write an url coding strategy class :
mount(new LocaleRequestTargetUrlCodingStrategy("fr/accueil",Home.class));
mount(new LocaleRequestTargetUrlCodingStrategy("en/home",Home.class));
class LocaleRequestTargetUrlCodingStrategy extends
AbstractRequestTargetUrlCodingStrategy {
...
encode(IRequestTarget requestTarget) {
}
matches(IRequestTarget requestTarget)
// but here how i can get the current locale to determine if /fr/accueil
or /en/home matchs this mounter ???
}
decode(RequestParameters requestParameters) {
// but here how i can change the current locale ?
}
...
}
thanks
igor.vaynberg wrote:
>
> write your own url coding strategy
>
> -igor
>
> On Sat, Mar 14, 2009 at 5:38 AM, manu161184 <ma...@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I want to define nice URL per language, and switch locale automatically
>> in
>> relation with url.
>>
>> For example :
>>
>> http://www.example.com/en/home.html --> Home.java (WebPage) with english
>> local
>> http://www.example.com/fr/accueil.html --> Home.java (WebPage) with
>> french
>> local
>>
>> I tried :
>>
>> In my WebApplication :
>>
>> mountBookmarkablePage("/en/home.html",Home.class);
>> mountBookmarkablePage("/fr/accueil.html",Home.class);
>>
>> Both urls are accessible and display home page, it's ok.
>>
>> In Home.html
>>
>> home page
>>
>> In Home.java :
>>
>> //i can get locale with request.getRequestURI() and check if url starts
>> with
>> "en" or "fr" (and i think is very bad)
>> new BookmarkablePageLink("homeLink", Home.class); // but here, how to
>> change
>> "href" with regard to locale?
>>
>> thanks,
>> Manu
>> --
>> View this message in context:
>> http://www.nabble.com/I18n-and-nice-URLs-tp22512232p22512232.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/I18n-and-nice-URLs-tp22512232p22553965.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: I18n and nice URLs
Posted by Igor Vaynberg <ig...@gmail.com>.
write your own url coding strategy
-igor
On Sat, Mar 14, 2009 at 5:38 AM, manu161184 <ma...@gmail.com> wrote:
>
> Hi,
>
> I want to define nice URL per language, and switch locale automatically in
> relation with url.
>
> For example :
>
> http://www.example.com/en/home.html --> Home.java (WebPage) with english
> local
> http://www.example.com/fr/accueil.html --> Home.java (WebPage) with french
> local
>
> I tried :
>
> In my WebApplication :
>
> mountBookmarkablePage("/en/home.html",Home.class);
> mountBookmarkablePage("/fr/accueil.html",Home.class);
>
> Both urls are accessible and display home page, it's ok.
>
> In Home.html
>
> home page
>
> In Home.java :
>
> //i can get locale with request.getRequestURI() and check if url starts with
> "en" or "fr" (and i think is very bad)
> new BookmarkablePageLink("homeLink", Home.class); // but here, how to change
> "href" with regard to locale?
>
> thanks,
> Manu
> --
> View this message in context: http://www.nabble.com/I18n-and-nice-URLs-tp22512232p22512232.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org