When we are making use of Resources in order to display tags of different languages, we may need different displays for the same culture, depending on a specific area (i.e. dialects), or customizations in the content depending on the requirements
Registering a new culture is an action which requires admin privileges elevated, ideally from cmd. You have more info in MSDN
In this post we are extending an existing culture, and testing the customizations on the new culture. We are making use of System.Globalization namespace, and additionally adding a reference to sysglobl assembly
The code for registering the culture begins with the creation of the culture in disk
This is the implementation:
This method has created an xml file with the customizations specified
The next step is loading the culture into the system, this is made reading the ldml (language definition markup language) defined in the xml
With the next implementation:
As result we have the culture installed into the system, in Windows/Globalization dir
Now it's time to test the new culture
Our web site has 2 sets of resources, and the next code in the index view
Registering a new culture is an action which requires admin privileges elevated, ideally from cmd. You have more info in MSDN
In this post we are extending an existing culture, and testing the customizations on the new culture. We are making use of System.Globalization namespace, and additionally adding a reference to sysglobl assembly
The code for registering the culture begins with the creation of the culture in disk
CreateCultureAndSaveIt(@"D:\culture.xml");
This is the implementation:
private static void CreateCultureAndSaveIt(string fileName)
{
CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder("en-US-NY", CultureAndRegionModifiers.Neutral);
CultureInfo parent = new CultureInfo("en-US");
builder.LoadDataFromCultureInfo(parent);
builder.LoadDataFromRegionInfo(new RegionInfo("US"));
builder.Parent = parent;
builder.RegionEnglishName = "New York";
builder.RegionNativeName = "New York";
builder.CultureEnglishName = "New York (United States)";
builder.CultureNativeName = "New York (United States)";
builder.NumberFormat.CurrencySymbol = "*";
builder.Save(fileName);
}
This method has created an xml file with the customizations specified
The next step is loading the culture into the system, this is made reading the ldml (language definition markup language) defined in the xml
LoadCultureAndRegisterIt(fileName);
With the next implementation:
private static void LoadCultureAndRegisterIt(string fileName)
{
CultureAndRegionInfoBuilder builder = CultureAndRegionInfoBuilder.CreateFromLdml(fileName);
builder.Register();
}
As result we have the culture installed into the system, in Windows/Globalization dir
Now it's time to test the new culture
Our web site has 2 sets of resources, and the next code in the index view