X hits on this document

136 views

0 shares

0 downloads

0 comments

36 / 67

12

.NET INTERNATIONALIZATION

to take certain steps to ensure that the x-en-GB or en-GB-Acme culture was used instead of the en-GB culture.

Regardless of how you approach this problem, you should be aware of the lim- its on custom culture names. The maximum length of a custom culture name is 84 characters, and each “tag” within the name is limited to 8 characters. A “tag” is a block of letters and numbers that is delimited by a dash (“-”) or an underscore (“_”). So a name of “en-GB-AcmeSoftware” is invalid because the “AcmeSoftware” tag is 12 characters long. You can work around this by delimiting words using dashes or underscores (e.g., “en-GB-Acme-Software” or “en-GB-Acme_Software”).

Supplemental Substitute Custom Cultures

A ”supplemental substitute” custom culture certainly sounds like a contradiction in terms. I use this term to describe a supplemental custom culture that exists to replace an existing culture without actually replacing it. In the “Public Custom Cultures and Naming Conventions” section, I discussed the problems with replacement custom cultures and suggested a solution in which, instead of creating a replacement custom culture, a new supplemental custom culture could be created that was in every way like the intended replacement custom culture. Creating a new custom culture that is like an existing custom culture is made easy with the LoadDataFromCultureInfo and LoadDataFromRegionInfo methods. This is the code for creating an en-GB- Acme supplemental substitute custom culture:

CultureInfo cultureInfo = new CultureInfo(“en-GB”); RegionInfo regionInfo = new RegionInfo(cultureInfo.Name);

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

// load in the data from the existing culture and region builder.LoadDataFromCultureInfo(cultureInfo); builder.LoadDataFromRegionInfo(regionInfo);

// make custom changes to the culture builder.GregorianDateTimeFormat.ShortTimePattern = “HH:mm tt”;

builder.Register();

Document info
Document views136
Page views136
Page last viewedFri Dec 02 18:32:31 UTC 2016
Pages67
Paragraphs859
Words13458

Comments