Replacing a specific culture.
var cultureBuilder = new CultureAndRegionInfoBuilder(
"kl-GL", CultureAndRegionModifiers.Replacement);
cultureBuilder.LoadDataFromCultureInfo(new CultureInfo("kl-GL"));
cultureBuilder.GregorianDateTimeFormat.MonthNames = new []
{
"jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "okt", "nov", "dec",
string.Empty // needs to be here!!!
};
cultureBuilder.Register();
Don't execute this! It will overwrite your culture settings. Adjust as you need it.
Creating a new specific culture.
static void Main(string[] args)
{
try
{
var builder = new CultureAndRegionInfoBuilder(
"kl-GL-custom",
CultureAndRegionModifiers.None);
// bind the properties
builder.LoadDataFromCultureInfo(new CultureInfo("kl-GL"));
builder.LoadDataFromRegionInfo(new RegionInfo("kl-GL"));
// make custom changes to the culture
builder.GregorianDateTimeFormat.MonthNames = new []
{
"jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "okt", "nov", "dec",
string.Empty // needs to be here!!!
};
// one time operation! needs admin rights!
builder.Register();
}
catch
{
}
Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture =
new CultureInfo("kl-GL-custom");
Console.WriteLine(DateTime.Today.ToString("MMMM"));
}
Using the new culture in ASP.NET is as trivial as adding this to your web.config:
<globalization culture="kl-GL-custom" uiCulture="kl-GL-custom"/>
or do this
protected override void InitializeCulture()
{
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("kl-GL-custom");
base.InitializeCulture();
}