views:

493

answers:

0

I spend hours and hours tried to figure this out why my ResourceManager won't pickup my Resource file?

Background:

  1. I create a custom CultureAndRegionInfoBuilder with code "km-KH" it registered without any problem.
  2. Add resource files Messages.resx; Messages.km-KH.resx & Messages.fr-FR.resx with key hello of value "Hello", "Soursdey" & "Bonjour" respectively.

Now if I tried to use my custom culture

Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture =
   CultureInfo.CreateSpecificCulture("km-KH");
ResourceManager rm = ResourceManager("app.Messages", typeof(...).Assembly);
var x = rm.GetString("hello"); // always return "Hello"

But if I use .NET build-in culture like "fr-FR"

Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture =
   CultureInfo.CreateSpecificCulture("fr-FR");
ResourceManager rm = ResourceManager("app.Messages", typeof(...).Assembly);
var x = rm.GetString("hello"); // return "Bonjour" -- correct.

Alright I tried another method with my custom culture

Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture = 
   CultureInfo.CreateSpecificCulture("km-KH");
// this time I give exact resource file app.Messages.km-KH
ResourceManager rm = ResourceManager("app.Messages.km-KH", typeof(...).Assembly);
var x = rm.GetString("hello"); // always return "Soursdey" -- correct value

Is there anyone could explain what was happen in this situation? Thanks.