X hits on this document





35 / 67


prefixing the culture name with the “x-” prefix, a statement is made that the culture is for “private” use—i.e., the use of one or a limited number of applications. This pre- fix also solves the problem that if Microsoft introduces a culture for the same lan- guage/region, no clash will occur (because Microsoft’s culture will not have the “x-prefix). The prefix solution represents a halfway house. It solves part of the prob- lem. Of course, if another application attempts to install a culture for the same lan- guage/region and uses the same name (including the prefix), then a clash will still occur.

If you are creating a replacement culture such as en-GB, your options are quite limited. If it is truly to be a replacement culture, changing the name is not an option. One option is to set up or seek out a public registry on the Internet for replacement custom cultures. If such a registry exists, it could be used to track requests for changes to existing cultures and offer a “standard” replacement culture upon which well-behaved applications could agree. The “standard” replacement culture would be the sum of all agreed-upon changes. Such a co-operative solution is optimistic and not guaranteed, and can be seen as only a “gentleman’s agreement.” Alternatively, you could simply overwrite the opposition’s replacement culture with your own. Immediately before your call to CultureAndRegionInfoBuilder.Register, you would add the following code:

try {


} catch (ArgumentException) {


This code attempts to unregister any existing en-GB culture and ignores any exception that would result from an existing en-GB replacement culture. If you choose this approach, be prepared for some hate mail. The only guaranteed solution is to use a supplemental custom culture instead of a replacement custom culture, and use the previously suggested naming convention to avoid a clash. The custom cul- ture would then be called something like “x-en-GB” or “en-GB-Acme” instead of en-GB”. The obvious downside to this solution is that the custom culture is no longer a replacement custom culture. This means that your application would need


Document info
Document views124
Page views124
Page last viewedWed Oct 26 22:12:16 UTC 2016