by Michael S. Kaplan, published on 2006/04/20 03:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/04/20/579579.aspx
Talking about ELKs (Enabling Language Kits) again, those cool things that provide new locales outside of operating system upgrades that I first mentioned in Lions and tigers and bearsELKs, Oh my! way back in January of last year.
More recently, in ELK cultures for other platforms, I answered a question about how to take one of those ELK locales that becomes a Windows Only Culture in the .NET Framework and get it onto a machine that does not contain that locale, such as Windows Server 2003 or Windows 2000 or NT 4.0 or even Windows 98/Me.
But Dave Sussman asked in a comment to that post:
We've hit the same problem with a requirement for Welsh locale support in an ASP.NET 2.0 web application. You don't explain how you create the LDML file and import it into server 2003 - any pointers?
Thanks
dave
So I figured providing a bit of sample code that showed how to do it might be in order....
We will be using the CultureAndRegionInfoBuilder Class, and the following members:
Basically, there are two bits of code to run, one on the XP SP2 machine (or whatever machine contains the locale from which you are getting data):
using System;
using System.Globalization;
namespace Testing {
class Test {
[STAThread]
static void Main(string[] args) {
CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder("cy-GB", CultureAndRegionModifiers.Replacement);
carib.LoadDataFromCultureInfo(new CultureInfo("cy-GB", false));
carib.LoadDataFromRegionInfo(new RegionInfo("cy-GB"));
carib.Save(@"c:\cy-GB.ldml");
}
}
}
And then the following code on Server 2003 (or whatever version of Windows does not have the locale in question):
using System;
using System.Globalization;
namespace Testing {
class Test {
[STAThread]
static void Main(string[] args) {
CultureAndRegionInfoBuilder carib = CultureAndRegionInfoBuilder.CreateFromLdml(@"c:\cy-GB.ldml");
carib.Register();
}
}
}
Now to compile these two binaries from the command line, remember to add the reference to sysglobl.dll with the following line:
csc /r:sysglobl.dll welsh.cs
And then you are all set, and you can use the culture in your managed code using version 2.0 of the .NET Framework!
This post brought to you by "ᠽ" (U+183d, a.k.a. MONGOLIAN LETTER ZA)
# Mike on 20 Apr 2006 1:23 PM:
# Michael S. Kaplan on 20 Apr 2006 2:32 PM:
# Andy Brown on 29 May 2006 7:35 PM:
referenced by
2010/09/10 Doing the minimum isn't always the best plan...
2006/11/22 Fixing the sample code for getting ELK cultures on other platforms
2006/05/18 Where are the other Tamils?