I'm trying to support multiple languages in a solution that has multiple projects and threads.
I have 2 resource files, one with English strings, and one with French strings.
I'm setting the current culture as follows:
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(isEnglish ? "en-US" : "fr-CA");
Is there a way to set the current culture globally, for the entire solution, or do I have to do this for each thread that needs to access strings?
To change the current UI culture, you assign the CultureInfo object that represents the new UI culture to the Thread. CurrentThread. CurrentUICulture property.
The CultureInfo. InvariantCulture property is used if you are formatting or parsing a string that should be parseable by a piece of software independent of the user's local settings. The default value is CultureInfo. InstalledUICulture so the default CultureInfo is depending on the executing OS's settings.
You specify the invariant culture by name by using an empty string ("") in the call to a CultureInfo instantiation method. CultureInfo. InvariantCulture also retrieves an instance of the invariant culture. It can be used in almost any method in the System.
In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.
In .NET Framework 4.5, the CultureInfo.DefaultThreadCurrentCulture Property gets or sets the default culture for threads in the current application domain.
In the .NET Framework 4 and previous versions, by default, the culture of all threads is set to the Windows system culture. For applications whose current culture differs from the default system culture, this behavior is often undesirable. In the .NET Framework 4.5, the DefaultThreadCurrentCulture property enables an application to define the default culture of all threads in an application domain.
You can add a globalization section within system.Web in the web.config
<globalization culture="en-US" uiCulture="en-US" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With