0

I am trying to set the culture in my application. Here is my code :

Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");

I am trying to set it to the MasterPage.master first. I have the MasterPage.master.resx and the MasterPage.master.fr.resx. The two file are set as Embedded Ressouce in the properties.

Here's my aspx element :

<asp:LinkButton runat="server" Text="" ID="lnkLangue" OnClick ="lnkLangue_Click" meta:resourcekey="lnklangue" ></asp:LinkButton>

I have set the lnkLangue.Text in the both resx file (en and fr).

My problem is the culture is always in english and never in french. I can set the culture to "fr-CA", nothing work (no french, only english). I tried to set the culture in the PageLoad event, Preinit, on a button click, etc, Nothing work.

I am using the framework 4.0

Am I missing something ?

Vinc 웃
  • 1,187
  • 4
  • 25
  • 64

1 Answers1

2

You will need to override the following method on each page that needs to be localized, or inherit from a base page that overrides the InitializeCulture method.

protected override void InitializeCulture()
{
   Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
   Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
   base.InitializeCulture();
}
Jesse Petronio
  • 693
  • 5
  • 11