Creating Custom Cultures C# Help

languages of the world are available with .NET.You can create a custom culture. Some examples of when  reating custom cultures can be useful are to support a minority within a region or to create . ubcultures for different  ialects.

Custom cultures and regions can be created with the class CultureAndRegion!nfoBuilder in the namespace Syst,m.Globalization. This class is located in the assembly sysglool!It the file sysglobl. dll.

With the ‘constructor of the class CuI tureAndRegionlnfoBuilder, you can pass the culture’s name. The second argument 0.£ the constructor requires an enumeration of type CuI tureAndRegionModifiers. This enumeration allows one of three values: Neutral for a neutral culture, Replacement if an existing Framework-culture should be replaced, or None. .

After the CuI tureAndRegionlnfoBuilder object is instantiated, you can configure the culture by setting properties. With the properties of this class, you can define all the cultural and regional . information such as name, calendar, number format, metric information, and so on. If the culture should be based on existing cultures and regions, you can set the properties of the instance using the methods LoadDataFromCul tureln~o () and oadDataFromRegionlnfo ( ), and change the values that are
different by setting the properties afterward.

Calling the method Register () registers the new culture with the operating system. Indeed, you can fin~e file that describes the culture in the directory <windows>\Globalization. Look for files with the extension . nIp.

The newly created culture can now be used like other cultures:

.

You can use the culture for formatting and also for resources. If you start the Cultures in Action application that was written earlier in this chapter again, you can see the custom culture as well.

Posted on November 2, 2015 in Localization

Share the Story

Back to Top