开发者

ASP.NET MVC: Localization issues (wrong resx file for culture)

I have a Strings.resx and a Strings.nl.resx file. The first contains a English string, the other a Dutch string. They are part of a C# Class Library project: Module.

 public static string testString()
 {          
      //I Force the culture to always be english
       Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
       Thread.CurrentThread.C开发者_Python百科urrentCulture = CultureInfo.GetCultureInfo("en-US");
       return Strings.Hello;
 }

When I call them from a simple Console Application, it works:

  Console.WriteLine(Module.testString()); //English string gets returned

When I do the same from my ASP.NET MVC application, I get the Dutch version...

    public ActionResult testCulture()
    {
        return Content(Module.testString()); //Dutch string gets returned..?!
    }

I am using a Dutch Windows, so any auto-setting will be Dutch.But how can I get a different string when the culture is hardcoded to en-us in the class library??

What am i missing here?


Do you have a Neutral Resources Language specified anywhere? If it is set to "nl" or "nl-NL", any request for a resource that is not found will eventually end up fetching the "nl" resource. Since you do not have a Strings.en-US.resx or Strings.en.resx, setting CurrentUICulture to "en-US" would make the system use the neutral resources language.


check if your web.config is not having a globalization tag having a language set to dutch

or

if you are using internet explorer, go to tools > internet options and click on language button, if it's showing dutch language before the english one, change it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜