Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net Mvc 2.0 RC Setting Thread CurrentCulture/Ui

I been pulling my hair out all day.

i can't seem to set the current thread cultureui or culture to anything other than English. In the controller i have

  protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            CultureInfo cultureInfo = CultureInfo.GetCultureInfo("fr-FR");

            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;                    
        }

in my view i have

<%= Thread.CurrentThread.CurrentUICulture.EnglishName%>  

the thread seems to be fine but as soon as the view renders some how its back to english!!

I know its a RC, so is it broken or am I missing something ??

cheers

Johnny

like image 986
Johnny Spittle Avatar asked Nov 05 '22 17:11

Johnny Spittle


1 Answers

Set the language later. I use a filter that runs before the action (OnActionExecuting).

My first shot at it would be to set it in the action.

like image 162
Mathias F Avatar answered Nov 11 '22 16:11

Mathias F