Persist the CurrentCulture

Answered
0
0

Hi guys.

I have been able to produce Localization resources for my new DevEx Dashboard, which works great. Also, I have the option for the user to set their preferred current language. The thing is, I am probably setting the CurrentCulture once at the application Load or whne the user changes it and never anymore, so the first Dashboard I show comes properly translated, but the subsequent ones go back to their original language, English. Where would be the right place to set the CurrentCulture in order to be properly available all the time?

Thanks in advance.

Ivan

  • You must to post comments
Best Answer
0
0

Hi Ivan, the Page is a property of the wrapper. Try in your Init ore PreInit or Load event to add

this.Page.Culture = this.Page.UICulture = culture.

If that is the solution we can add it to the AspNetWrapper.

  • You must to post comments
0
0

Thank you Luca!

You nailed it.

  • You must to post comments
0
0

Hi Levie.

Trying to find a solution to this, I arrived at the DevEx documentation page where they instruct us to use the InitializeCulture in order to be able to set the Application Culture ( https://docs.devexpress.com/AspNet/12050/common-concepts/localization/satellite-resource-assemblies ). In the Runtime session of this page there is a sample on how it should be done. However, we don’t get the InitializeCulture in our Pages/Windows. Would there be a way to do something in order to follow their instruction in a Wisej fashion?

I think the fact that if we put a break point at the time we set the Culture and this makes it work is a good clue, for you guys, of what could be going on.

PS: this is the Method mentioned: https://docs.microsoft.com/pt-br/dotnet/api/system.web.ui.page.initializeculture?view=netframework-4.8#System_Web_UI_Page_InitializeCulture

 

  • You must to post comments
0
0

Hey, this looks like it is going to be one of those tricky ones… at least for me.

I spoke too soon. It works at times, it doesn’t in others. I even put the CurrentCulture setting in all events (PreInit, Load and DataLoading) and sometimes, even if set to Portuguese, for example, it comes in English. Then, I put a break point at the time I set the CurrentCulture and it worked just fine. I guess the ASP.NET thing of talking back and forwards has something to do, but why would we loose the CurrentCulture settings?!

I tried using Thread.CurrentThread.CurrentCulture instead of the Application.CurrentCulture too, but same results. I think I have a problem… 🙂

  • You must to post comments
0
0

Hi Levie.

Success!

Tried the Load, didn’t work. Tried the PreInit, it worked perfectly.

Thank you.

 

  • You must to post comments
0
0

Hi Levie.

Thanks for the reply!

Yep, I am doing it in the Program.Main and then later if the user chooses a different language. It is all fine with my Wisej controls, the thing is with the DevEx Dashboard wrapper. The first Dashboard I open comes properly localized, after this one, all others are not localized anymore. It is like the “main thread” is respecting the CurrentCulture and the first Dashboard is opened in it, but then the others come in a different “thread” where CurrentCulture hasn’t been changed.

Yes, I am using the latest from Wisej.

Thanks.

Ivan

  • You must to post comments
0
0

Hi Ivan,

You can do it in Program.Main and it should work correctly. I know you had some issues with setting the localization before, any chance we can get a small sample demonstrating the issue?

Are you using the latest version of Wisej?

Best,

Levie

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.