1

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

yang-qu
  • 2,144
  • 4
  • 20
  • 26
  • What do you want to do with the custom culture? Why do you think you need one? – Paul van Brenk Jul 30 '09 at 05:45
  • Can you plz post your code........ – Muhammad Akhtar Jul 30 '09 at 06:23
  • Just out of curiosity, what culture have you discovered/invented that cannot be appropriately represented by one of the existing culture types? – Rex M Jul 31 '09 at 00:10
  • I can CultureAndRegionInfoBuilder to create a custom culture, the problem is that it will register it which requires full access to the local computer. What if my program doesn't have full access privileges, which means I cannot install my new custom culture and I cannot use it. This is why I do it in this way. It's similar to this http://stackoverflow.com/questions/1059677/custom-culture-for-client-specific-verbiage – yang-qu Jul 31 '09 at 00:21

2 Answers2

2

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 Domeny
  • 4,410
  • 2
  • 33
  • 49
  • This comment was very helpful, I hadn't come across this w3c guide to locales. I'd previously been toying with the idea of breaking Australian regions down to state, such as the ISO-3166-2 standards en-AU-VIC, en-AU-WA etc., knowing that I actually wanted custom subdivisions such as en-AU-WEST and en-AU-EAST. Good to know these should be implemented as private-use tags with the -x- part added. – misteraidan Mar 16 '15 at 23:31
1

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
  • 11
  • 1
  • I have to agree with your statement. CultureInfo is broken into language and region, however some of the cultures are region specific etc Japanese is ja. What happens when you want to view something that is language (Japanese) and region (US) ... – Jonathan Jun 22 '11 at 16:06