By default .NET runtime uses a satellite assembly matching the language of the operating system itself. This means that on English operating system the runtime uses English assembly file. In most cases this is the right thing to do. However a better choice is to use the satellite assembly matching the default culture of the operating system. Many users use English operating system but their default localize is not English but some other. To use the default culture instead of language of the operating system itself you have to add one line of code. Set Thread.CurrentThread.CurrentUiCulture property to change the user interface culture. The CultureInfo.CurrentCulture property contains the default culture of your system. This setting is specified in Regional and Language Options of Control Panel.
The above image contains case where an English Windows XP has Finnish as default culture (e.g. locale). Without modification a .NET application will start up in English. If you want it to start up using the default culture (in this case Finnish) follow the instructions below.
The following examples show how to set the user interface culture. Add lines written in bold typeface.
Note! Even Sisulizer can localize your application properly it can not run (Project | Run Localized) it in desired language if you do not set the user interface culture to match the default culture.
Set the culture in the Main function (Program.cs).
using System.Globalization;
using System.Threading; static void Main() { // Add this line of code Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
Add contructor in the App class (App.xaml.cs) and set the culture there.
using System.Globalization;
using System.Threading; public partial class App : Application
{ // Add these lines of code public App()
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture;
}
}
Set the culture in the constructor of the main form.
Imports System.Globalization
Imports System.Threading Public Class Form1 ... Public Sub New() ' Add this line of code Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture ' This call is required by the Windows Form Designer. InitializeComponent() End Sub ... End Class
Set the culture in the initialization section.
implementation uses System.Threading, System.Globalization; initialization // Add this line of code Thread.CurrentThread.CurrentUICulture := CultureInfo.CurrentCulture; end