X hits on this document





62 / 67



Windows XP Professional Service Pack 2, for example, has many more cultures avail- able to it than Windows 2000 Professional. If your application needs to use a culture that is available to only a more recent version of Windows, your first thought might be to upgrade your clients to that version of Windows. A simpler solution, however, would be to export the required culture from the version of Windows that has the culture to the machines that do not have the culture. For example, you could export the Welsh (United Kingdom) culture from Windows XP Professional Service Pack 2 to, say, Windows 2000 Professional (where this culture is not known). This approach becomes especially useful when newer versions of Windows are released and you covet their new cultures but don’t want to upgrade your development machines.

This process is wrapped up in the CultureAndRegionInfoBuilderHelper. Export method, which can be called like this:

CultureAndRegionInfoBuilderHelper.Export( new CultureInfo(“cy-GB”), “cy-GB.ldml”,



The static Export method accepts four parameters: the CultureInfo to export, the filename to export the definition to, the text info culture that the exported culture should use, and the sort culture that the exported culture should use. The export method starts with some easily recognizable code that simply creates a new Cul- tureAndRegionInfoBuilder object and loads its values from the existing culture:

RegionInfo regionInfo = new RegionInfo(cultureInfo.Name);

CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder(cultureInfo.Name, CultureAndRegionModifiers.Replacement);

builder.LoadDataFromCultureInfo(cultureInfo); builder.LoadDataFromRegionInfo(regionInfo);


Notice that the exported culture appears at first to be a replacement culture, but this is only a ruse to allow the culture to be saved on the machine that already has the culture. The exported culture file (e.g., cy-GB.ldml) cannot be used immediately on the target machine, however. One issue needs to be addressed first. If you open the

Document info
Document views110
Page views110
Page last viewedTue Oct 25 22:38:56 UTC 2016