Create custom culture in ASP.NET

You can create a new culture based on an existing culture:

string culture = "en-sg";
string name = "Singaporean English";

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

CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = new CultureAndRegionInfoBuilder(culture, CultureAndRegionModifiers.None);

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

// Custom Changes
cultureAndRegionInfoBuilder.CultureEnglishName = name;
cultureAndRegionInfoBuilder.CultureNativeName = name;

cultureAndRegionInfoBuilder.Register();

Added:
Just checked the references:
I have :

using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;

Added (updated, based on comments):

With regards the error message:

The error you’re seeing is the result of some resource naming conflict. Check the resource names, these get compiled into dlls to you need to check that the namespace names dont conflict. You can check this using the reflector tool: http://www.red-gate.com/products/reflector/

Leave a Comment