- Localize at Sample Level
- Editing Default Resource File
- Localize Resource File with Different Assembly or Namespace
Contact Support
Localization in Windows Forms Form (SfForm)
21 Jan 20253 minutes to read
Localization is the process of translating the application resources into different language for the specific cultures. The SfForm can be localized by adding resource file. Application culture can be changed by setting CurrentUICulture before InitializeComponent
method.
Localize at Sample Level
To localize the SfForm based on CurrentUICulture
using resource files, follow the below steps.
-
Create new folder and named as Resources in your application.
-
Add the default resource file of SfForm into Resources folder. You can download the
Syncfusion.Shared.Base.resx
here.
-
Right-click on the Resources folder, select Add and then NewItem.
-
In Add New Item wizard, select the Resource File option and name the filename as Syncfusion.Shared.Base.<culture name>.resx. For example, have to give name as Syncfusion.Shared.Base.de-DE.resx for German culture.
- The culture name that indicates the name of language and country.
- Now, select
Add
option to add the resource file in Resources folder.
- Add the Name/Value pair in Resource Designer of Syncfusion.Shared.Base.de-DE.resx file and change its corresponding value to corresponding culture.
-
Now, set the
CurrentCulture
of the Application before theInitializeComponent
method and Run the sample.public Form1() { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE"); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE"); InitializeComponent(); }
Public Sub New() System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("de-DE") System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("de-DE") InitializeComponent() End Sub
Editing Default Resource File
The default resource file can be edited by adding it to Resources folder of the application where SfForm reads the static texts from here. The default resource file can be download from here.
Now, change the Name/Value pair in Resource Designer of Syncfusion.Shared.Base.resx
file.
Localize Resource File with Different Assembly or Namespace
If resource (.resx) files are added into different assembly other than start up application, call the SetResources
method of LocalizationResource
follows.
public Form1()
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");
LocalizationResourceBase.SetResources(typeof(ClassName).Assembly, "NameSpace");
InitializeComponent();
}
public Form1()
{
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("de-DE")
LocalizationResourceBase.SetResources(GetType(ClassName).Assembly, "NameSpace")
InitializeComponent()
}