Home > Articles > Programming > Windows Programming

This chapter is from the book

Company-Specific Dialects

As mentioned in "Uses for Custom Cultures," at the beginning of this chapter, it can be useful to create a set of resources that use a vocabulary that is specific to a single company or group of companies. The CreateChildCultureAndRegionInfoBuilder method does just this and can be used like this:

CultureAndRegionInfoBuilder builder =
    CultureAndRegionInfoBuilderHelper.
    CreateChildCultureAndRegionInfoBuilder(
    new CultureInfo("en-US"),
    "en-US-Sirius",
    "English (United States) (Sirius Minor Publications)",
    "English (United States) (Sirius Minor Publications)",
    "United States (Sirius Minor Publications)",
    "United States (Sirius Minor Publications)");

builder.Register();

The method accepts a culture (e.g., "en-US") to inherit from, and accepts the new culture name and various strings to set various name properties to. It returns a CultureAndRegionInfoBuilder object that can be used to register the culture. The CreateChildCultureAndRegionInfoBuilder method follows:

public static CultureAndRegionInfoBuilder
    CreateChildCultureAndRegionInfoBuilder(
    CultureInfo parentCultureInfo, string cultureName,
    string cultureEnglishName, string cultureNativeName,
    string regionEnglishName, string regionNativeName)
{
    RegionInfo parentRegionInfo =
       new RegionInfo(parentCultureInfo.Name);

    CultureAndRegionInfoBuilder builder =
        new CultureAndRegionInfoBuilder(cultureName,
        CultureAndRegionModifiers.None);

    // load the culture and region data from the parent
    builder.LoadDataFromCultureInfo(parentCultureInfo);
    builder.LoadDataFromRegionInfo(parentRegionInfo);

    builder.Parent = parentCultureInfo;
    builder.CultureEnglishName = cultureEnglishName;
    builder.CultureNativeName = cultureNativeName;
    builder.RegionEnglishName = regionEnglishName;
    builder.RegionNativeName = regionNativeName;

    return builder;
}
  • + Share This
  • 🔖 Save To Your Account