开发者

ASP.NET Localization - use default resource

开发者 https://www.devze.com 2022-12-24 14:08 出处:网络
I am running into trouble given the following setup: Operating System is Windows 7 English, Format is German (Germany),开发者_如何学运维 Location is Germany

I am running into trouble given the following setup:

  • Operating System is Windows 7 English, Format is German (Germany),开发者_如何学运维 Location is Germany
  • My Application (MVC2, .NET 4) contains 2 Resource-Files, Labels.resx (containing German content) and Labels.en.resx (containing English content)
  • CurrentCulture and CurrentUICulture are set to de-DE very early (by initializing the controller)

But the framework chooses to take the Labels.en.resx instead of using what I am expecting, the default one. So why does the fallback mechanism not work here? Any ideas?


Seems to be a bug related to ASP.NET 4.0. When compiling the project against 3.5 all works as expected.


It looks like the fallback works a bit differently.

If you have your browser languages set to eg.

Polish (pl), English GB (en-GB), English (en)

and you have corresponding resource files + a default resource file (e.g Literals.pl.resx, Literals.en-GB.resx, Literals.en.resx, Literals.resx) the the fallback mechanism will go:

  • Literals.pl.resx -> Literals.resx (if you have Polish first in your browser)
  • Literals.en-GB.resx -> Literals.en.resx -> Literals.resx (if you have English GB first in your browser)

The fallback works for locale, not language.

0

精彩评论

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

关注公众号