Create custom culture in ASP.NET

Posted by Billy on Stack Overflow See other posts from Stack Overflow or by Billy
Published on 2009-08-20T07:24:00Z Indexed on 2010/06/07 12:02 UTC
Read the original article Hit count: 358

I want to create a resource file for Singaporean English (en-sg) named "shopping.en-sg.resx" in App_GlobalResources folder.

I get error during compilation.

Error 1 The namespace 'Resources' already contains a definition for 'shopping' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web\2cd6afe9\737b0a13\App_GlobalResources.vomuzavz.1.cs 26

After searching Google, I discover that "en-sg" is not a default culture and I have to create custom culture for it. I don't know the detailed steps of this.

What should I do to create the culture and remove the compilation error?

I follow the example in MSDN, create a file called "shopping.x-en-US-sample.resx" and put the following code into BasePage's function (protected override void InitializeCulture()):

CultureAndRegionInfoBuilder cib = null;

cib = new CultureAndRegionInfoBuilder(
  "x-en-US-sample", CultureAndRegionModifiers.None);

CultureInfo ci = new CultureInfo("en-US");
cib.LoadDataFromCultureInfo(ci);
RegionInfo ri = new RegionInfo("US");
cib.LoadDataFromRegionInfo(ri);

cib.Register();

ci = new CultureInfo("x-en-US-sample");

However, compilation error is still exist.

UPDATED:

You can easily reproduce the problem by creating an empty website and two files "shopping.en-sg.resx" and "shopping.resx" in the app_globalresources folder.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about internationalization