c# - localization with resource file not working when setting culture at runtime -


i'm setting page culture @ runtime in code-behind this:

system.threading.thread.currentthread.currentculture = new cultureinfo("fr-fr"); system.threading.thread.currentthread.currentuiculture = new cultureinfo("fr-fr"); page.culture = "fr-fr"; 

the resource files in globalresource folder , i've got 2 files: somefile.resx , somefile.fr.resx

in markup page, have literal looks this:

<asp:literal runat="server" id="test" text="<%$ resources:somefile, somekey%>" /> 

if code sets culture commented out literal take value that's in somefile.resx if run code sets culture value that's in somefile.resx file instead of value that's in somefile.fr.resx file. tried culture info set "fr" see if makes difference doesn't.

what need change?

thanks.

the microsoft article locating localized resources provides example of how this. you've written, looks not creating new resourcemanager object use culture:

private resourcemanager rm { get; set; }  protected void page_load() {   var newculture = new cultureinfo("fr-fr");   thread.currentthread.currentculture = newculture;   thread.currentthread.currentuiculture = newculture;   page.culture = "fr-fr";   this.rm = new resourcemanager("somefile", typeof(program).assembly);    this.test.text = rm.getstring("somekey"); } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -