Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CultureInfo: Haitian Creole and .NET 3.5 on ASP.NET/MVC?

It's been easy to get French and Spanish translations added to our site, but we want to add Haitian Creole now and there is no Culture support for it. What's the best way to get this done?

like image 790
Kyle Avatar asked Aug 02 '10 17:08

Kyle


1 Answers

You can create the culture through .Net using the CultureAndRegionInfoBuilder class. As this code needs to run with administrative privileges, it's generally advised that you do it as a separate program or script that runs as part of the installation stage of the software. Once it's set up, you can use it like any other Culture.

This example is based on the example in the MS .Net Application Development Foundation book (2nd ed. p697):

var builder = new CultureAndRegionInfoBuilder("en-PL", CultureAndRegionModifiers.None);
builder.LoadDataFromCultureInfo(new CultureInfo("en-US"));
builder.LoadDataFromRegionInfo(new RegionInfo("US"));

builder.CultureEnglishName = "Pig Latin";
builder.CultureNativeName = "Igpay Atinlay";
builder.IsMetric = true;
builder.ISOCurrencySymbol = "PLD";
builder.RegionEnglishName = "Pig Latin Region";
builder.RegionNativeName = "Igpay Atinlay Egionray";

builder.Register();

Once that's done, you can retrieve your culture in the program.

var culture = new CultureInfo("en-PL");
like image 50
Matt Avatar answered Nov 15 '22 04:11

Matt