views:

166

answers:

2

How can I force and application and any threads that are started by that application to run under a specific culture?

I have tried the following but I still get exceptions in English. My understanding was that the wording on exceptions are translated using the active culture.

    static void Main(string[] args)
    {

        Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES", true);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES", true);

        try
        {
            int number = Convert.ToInt32("not a number");

        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }

        Console.WriteLine("Press any key to continue...");
        Console.ReadLine();
    }

Output: Input string was not in a correct format.

shouldn't it be in Spanish?

A: 

Globalization and Localization - I think you must read this article - Globalization/Localization

However, setting up a new culture will directly affect currency, datetime, and other language & country (culture) settings.

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-ES", true); Thread.CurrentThread.CurrentUICulture = new System.Globalization. CultureInfo("es-ES", true);

decimal a = 122221.23m;
Console.WriteLine(DateTime.Now);
Console.Write(a);
adatapost
A: 

see here the answer of Aku

ArsenMkrt