views:

713

answers:

2

Hi all,

I created a CustomCulture class form CultureInfo.

Here is my code:

public class CustomCulture : CultureInfo

{
private string _parent;
private string _name;
private string _description;

   public CustomCulture(string parentCulture, string myCultureName) : base(parentCulture)   
   {   
       _parent = parentCulture;   
       _name = myCultureName;   
       _description = String.Format("custom culture({0})", _name);   
   }   
   public override string Name   
   {   
       get  
       {   
           return _parent + "-" + _name;   
       }   
   }   
   public override CultureInfo Parent   
   {   
       get  
       {   
           return new CultureInfo(_parent);   
       }   
   }   
   public override string EnglishName   
   {   
       get  
       {   
           return _description;   
       }   
   }   
   public override string NativeName   
   {   
       get  
       {   
           return _description;   
       }   
   }

}

public partial class _Default : System.Web.UI.Page

{ private DefCulture.CustomCulture abc = new DefCulture.CustomCulture("en-AU", "abc");

protected override void InitializeCulture()
{
    Thread.CurrentThread.CurrentUICulture = abc;
}

....

What I want to achieve is, for example, if I create a custom culture en-AU-abc, the current page can use local resource file Default.aspx.en-AU-abc.resx,

but I couldn't get it work, the current page always loads Default.aspx.resx

A: 

pb, Rex M: Two cultures not supported by .NET that are very often required: en-ID, es-US. I love that because you haven't encountered this limitation of .NET that you choose to take a condescending attitude - because clearly a person asking a question you don't have an answer for must not know what they're doing. Why do you think Microsoft introduced the CultureAndRegionInfoBuilder class in .NET 2.0?

Jeremy
A: 

Try installing the custom culture. See Microsoft Locale Builder to create an .msi and run it to install your custom locale (requires Vista or later). I was able to get it working on Vista with App_GlobalResources.

BTW, custom locales with private-use extensions require -x-, for example, en-AU-x-abc. See Constructing language tags

Doug D