X hits on this document





30 / 67



IetfLanguage. After the call to Register in the example, there will be an entry with a key of “en-GB” and a value of “en-GB”, indicating that the en-GB custom culture has an IetfLanguage of “en-GB”.

This approach is fine for registering the custom culture on your own machine, but it isn’t very generic. If you want to create three custom cultures—say, en-GB, fr-FR, and es-ES—on your users’ machines, you would have to either create one applica- tion, called, for example, CreateAndRegisterAllThreeCultures, or create three separate applications—such as Create_enGB_Culture, Create_frFR_Culture, and Create_esES_Culture. A better solution is to create a single custom culture registration program and pass it custom culture files. In the source code for this book, you will find the RegisterCustomCulture console application, which exists for this purpose. RegisterCustomCulture accepts one or more LDML custom cul- ture files to register. LDML is the Locale Data Markup Language and is defined in Unicode Technical Standard #35 (see http://www.unicode.org/reports/tr35/). It is an extensible XML format for the exchange of structured locale data, and it is the for- mat that Microsoft chose for importing and exporting custom cultures. Although LDML is clearly defined by the Unicode Consortium, there is wide variation in its use. If you intend to use LDML files created by sources other than the CultureAn- dRegionInfoBuilder, be prepared to modify the LDML before it can be consumed by a CultureAndRegionInfoBuilder. An LDML file can be created using the Cul- tureAndRegionInfoBuilder.Save method, so the previous example could be rewritten like this:

CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder(“en-GB”, CultureAndRegionModifiers.Replacement);

builder.GregorianDateTimeFormat.ShortTimePattern = “HH:mm tt”;


This code would become part of the application’s build process, resulting in the en-GB.ldml file, which would become part of the application’s installation process. The file can be loaded simply by using the CultureAndRegionInfoBuilder.Cre- ateFromLdml method:

Document info
Document views131
Page views131
Page last viewedFri Oct 28 14:30:08 UTC 2016