PDA

View Full Version : Localization Implementation Changes


Aleks Seovic
09-08-2005, 04:01 AM
I refactored localization support and added support for ILocaleResolver strategy, which has been on my plate for quite a while.

You can find more information in the "User Locale Management" section of the "Spring.Web Localization" page on the wiki (http://opensource2.atlassian.com/confluence/spring/display/NET/Spring.Web+Localization).

Imprtant thing to note is that the default behavior has changed. Original implementation always used something similar to SessionLocaleResolver, while current implementation uses DefaultWebLocaleResolver.

If you have code that depends on the "legacy" behavior, you will have to configure LocaleResolver property to use session or cookie locale resolver, as described on the wiki.

Sorry for the inconvinience,

Aleks

crabo
09-14-2005, 03:48 AM
<object id="BasePage" abstract="true">
<property name="Master">
<ref object="MasterPage"/>
</property>
<property name="LocaleResolver">
<object type="Spring.Web.Localization.Resolvers.CookieLocaleReso lver, Spring.Web"/>
</property>
</object>

Do u mean I should add "Localization.Resolvers" property to every page object?

And, I'm very intresting on CookieLocaleResolver.
Could you pls give me a more specify example?
I tried that in FrameSet.
but only the page i set UserLocale changed!!

Do u mean I should add
this.UserLocale = new CultureInfo(...)
every page?

SO crazy,aha?

Thank you.

Aleks Seovic
09-14-2005, 05:47 AM
Yes and no...

Each page needs to know which resolver to use, so you do need to define resolver for all of them. However, you should probably create an abstract base definition and set it only there (as in the example above), and then make all the other pages in the application extend from that one by adding parent="BasePage" attribute to their definitions.

This is generally a good practice and it will help you inject common values that are shared by all (or many) pages, such as master page reference and locale resolver, as in this example.

Regards,

Aleks

crabo
09-14-2005, 07:34 AM
But how about frameset?

Should I change Frameset to Master/Child page?

in fact , i like frameset better.

Aleks Seovic
09-14-2005, 02:09 PM
In general, frameset should work as well, as long as each of the pages that's loaded by the frameset inherits from Spring.Web.UI.Page.

However, because each frame is a separate page, when you change the language in one of them only that one will be refreshed -- you will have to refresh other frames either manually or by generating necessary JavaScript that will do it for you.

- Aleks

crabo
09-15-2005, 01:52 AM
I'm so sorry for hadn't described my problem well enought.

I use frameset : these pages calls: Header; Lefter; Main.

when I use cookieLocalResolver, When ther Header change cultureInfo, ALL pages would be reload by javascript. but, nothing change,except the Header.

When I debug, I found that the Lefter can not get the
cookie["Spring.UserLocal"]. It's always NULL. when the Header gets.

2).
In my frameset pages, when I rebuid the project. browse the frame.
then , I'm certainly will encounter this exception:
Spring.Context.ApplicationContextException: Existing context 'Spring.Context.Support.WebApplicationContext' already registered under name '/Web'.

spring.net\src\spring\spring.web\web\support\abstr acthandlerfactory.cs Row: 70

[ApplicationContextException: Existing context 'Spring.Context.Support.WebApplicationContext' already registered under name '/Web'.]
Spring.Web.Support.AbstractHandlerFactory.GetAppli cationContext(HttpContext context) in e:\work\temp\spring\spring.net\src\spring\spring.w eb\web\support\abstracthandlerfactory.cs:70
Spring.Web.Support.PageHandlerFactory.GetHandler(H ttpContext context, String requestType, String url, String path) in e:\work\temp\spring\spring.net\src\spring\spring.w eb\web\support\pagehandlerfactory.cs:67
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String requestType, String path, String pathTranslated, Boolean useAppConfig)
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)



how can i resolve this?