1

I have an ASP.net MVC site, which I want to use a couple of resource files to set some strings.

I have a class library containing my viewmodels, and I have added a resource file (ValidationMessages) there, with a single string (called Test), and then have a property like so in my view model:

        public string TestResource
        {
            get
            {
                return ValidationMessages.Test;
            }
        }

And that works fine, when output on my view like so:

<div>@Model.TestResource</div>

If I add a ValidationMessages.en-au.resx (my default would be en-gb) file to my class library and create a different version of the test string, and then have the following in my global.asax:

 protected void Application_AcquireRequestState(object sender, EventArgs e)
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-au");
     Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-au");
 }

And this also works fine.

What I want to do is add a custom culture 'en-gb-ly' - I have registered this culture on my machine ok (using code from here). When I set the current culture to "en-gb-ly" in my global.asax and include a ValidationMessages.en-gb-ly.resx in my class library, the output has reverted back to the 'base' version of the Test string, not the one in my en-gb-ly resource.

Anybody any idea why this might be happening?

Community
  • 1
  • 1
Paddy
  • 33,309
  • 15
  • 79
  • 114
  • Quick check--is there some typo? You wrote you added custom culture 'en-xx' but then did a test with 'en-ly'. Did you mean 'en-ly' instead of 'en-xx'? – Clafou Oct 25 '12 at 11:32
  • Sorry, Clafou - typo, now fixed. – Paddy Oct 25 '12 at 11:35
  • Aha - problem now seems to be solved. I had been mucking about earlier and had added and subsequently removed an en-us resource file - this DLL was still present in my build folder - removing it and rebuilding has sorted it out... – Paddy Oct 25 '12 at 11:45

1 Answers1

1

A first thing to check is that the en-ly satellite assembly gets deployed as expected. Unfortunately if your custom culture is not installed on your build machine, then it won't even get built!

Clafou
  • 15,250
  • 7
  • 58
  • 89
  • Had a look (updated question as well, as a bit simpler) - my custom culture is "en-gb-ly" and in the bin folder for my class library, I have an en-gb-ly folder with a dll present. – Paddy Oct 25 '12 at 11:44
  • Going to mark this as the answer, as it pointed me in the direction to look, which sorted this out. – Paddy Oct 25 '12 at 11:54