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 ?

7
  • Where, exactly, do you set the culture? Which event? Commented May 29, 2014 at 19:31
  • This is what I dont know, where to set it ? I tried everywhere Commented May 29, 2014 at 19:39
  • Define "everywhere" by showing us some code. Commented May 29, 2014 at 19:40
  • In the pageload event, preinit, on a button click, I said it in the question Commented May 29, 2014 at 19:41
  • Try the PreInit event on a page, not the master page and see if that works. Also, please confirm that the resources work at all, by changing the English version of the resource and seeing if that displays on the page. Commented May 29, 2014 at 19:43

1 Answer 1

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(); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.