Creating a custom culture involves two steps:
Both steps are achieved using the .NET Framework 2.0 CultureAndRegion InfoBuilder class. We start with a simple example of creating a replacement culture to see the process through from beginning to end. We return to the subject later to create more complex custom cultures. In this example, the culture is a replacement for the en-GB English (United Kingdom) culture. The purpose of this culture is to change the default ShortTimePattern to include the AM/PM suffix (just like the en-US Short-TimePattern). The ShortTimePattern is a .NET Framework property and is not part of the Win32 data, so this value cannot be set in the Regional and Language Options dialog. The following code creates a replacement custom culture and registers it: // create a CultureAndRegionInfoBuilder for a // replacement for the en-GB culture CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder("en-GB", CultureAndRegionModifiers.Replacement); // the en-GB's short time format builder.GregorianDateTimeFormat.ShortTimePattern = "HH:mm tt"; // register the custom culture builder.Register(); The CultureAndRegionInfoBuilder constructor accepts two parameters: the custom culture name and an enumeration identifying what kind of custom culture the new culture is. The replacement culture is registered using the Register method. Once registered, all .NET Framework 2.0 applications on this machine will use the modified en-GB culture instead of the original, without any change to those applications. |