tags:

views:

14

answers:

1

Hi,

I have a web application that will use a few different cultures, one of which is es-US (Spanish United States). However, Windows XP do not have any support for the culture es-US. To work around the problem, I've found out that one is supposed to be able to use the CultureAndRegionInfoBuilder. So I looked into CultureAndRegionInfoBuilder and did the following:

On a Windows 7 machine I saved the culture es-US to an XML-file, as follows:

private static void SaveCultureToFile() {
            try {
                CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = null;
                Console.WriteLine("Saving es-US to xml disc...\n");
                cultureAndRegionInfoBuilder = new CultureAndRegionInfoBuilder("es-US", CultureAndRegionModifiers.Replacement);

                // Populate the new CultureAndRegionInfoBuilder object with culture information.
                CultureInfo ci = new CultureInfo("es-US");
                cultureAndRegionInfoBuilder.LoadDataFromCultureInfo(ci);

                cultureAndRegionInfoBuilder.Save("es-US.xml");

            }

Then I have a function that reads the xml, and registeres the culture into the system, as follows:

    private static void RegisterCultureFromDisk() {
        try {
            CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = null;
            Console.WriteLine("Loading es-US from xml...\n");
            cultureAndRegionInfoBuilder = CultureAndRegionInfoBuilder.CreateFromLdml("es-US.xml");
            Console.WriteLine("Culture is registred to the system...\n");
            cultureAndRegionInfoBuilder.Register();
            Console.WriteLine("The following culture has been registred to the system: \n");

        }

So I run the program using the SaveCultureToFile method on a Windows 7 machine, thus saving the culture to an xml file. Then I copy the files to the Windows XP machine, and runs the same program but the RegisterCultureFromDisk() method. But the program fails in the CultureAndRegionInfoBuilder.CreateFromLdml("es-US.xml") method saying that:

"Culture name 'es-us' is not supported"

Well, thats exactly why I'm trying to load the culture from the xml and registering it into the system.

Do any one know what I'm doing wrong, or how I can create the es-us culture at the Windows XP machine?

Thanx!

A: 

From MSDN:

Note that a custom culture can be registered on a computer only by a user who has administrative rights on that computer. Consequently, typical applications cannot create a custom culture.

I suspect it might be the cause of your problem... do you have admin rights on this machine ?

Thomas Levesque
Yes I do, and I don't think this is what causes the problem. Found some useful information at http://www.codeproject.com/KB/books/CustomCultures.aspx. Seems that msLocale:textInfoName and ms:LocalesortName cannot refer to a culture that the machine doesn't have. Consequently, it seems impossible to have a full featured es-us culture registered at a windows xp machine. One can however create a custom culture that resembles the es-us culture as much as possible.
Clean
I'm pretty sure it *can* refer to a culture the machine doesn't have, that's the whole point of creating a new culture. Once I created a "martian" culture, just to see if it was possible, and it worked fine
Thomas Levesque