Localization in WPF DataGrid (SfDataGrid)

Localization is the process of translating the application resources into different language for the specific cultures. You can localize the SfDataGrid by adding resource file. Application culture can be changed by setting CurrentUICulture before InitializeComponent() method.

Below application culture changed to German.

public MainWindow()
{
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");

    InitializeComponent();
}

To localize the SfDataGrid based on CurrentUICulture using resource files, follow the below steps.

1.Create new folder and named as Resources in your application.
2.Add the default resource file of SfDataGrid into Resources folder. You can download the Syncfusion.SfGrid.WPF.resx here.

Addition of default resource file of WPF DataGrid into Resources folder

3.Right-click on the Resources folder, select Add and then NewItem.

4.In Add New Item wizard, select the Resource File option and name the filename as Syncfusion.SfGrid.WPF.<culture name>.resx. For example, you have to give name as Syncfusion.SfGrid.WPF.de.resx for German culture.

5.The culture name that indicates the name of language and country.

Shows the name of resource file to be added for WPF DataGrid

6.Now, select Add option to add the resource file in Resources folder.

Shows the added resource file for German language in WPF DataGrid

7.Add the Name/Value pair in Resource Designer of Syncfusion.SfGrid.WPF.de.resx file and change its corresponding value to corresponding culture.

Shows the added resource file name / value pair in the resource designer in WPF DataGrid

Shows the localized in German for WPF DataGrid

You can get the sample from here

Localize when the resource file present in different assembly or different namespace?

By default, SfDataGrid try to read the resource file from executing assembly and its default namespace by using Assembly.GetExecuteAssembly method. When the resource file is located at different assembly or namespace, then you can let SfDataGrid know by using GridResourceWrapper.SetResources method.

public MainWindow()
{
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");            
    Syncfusion.UI.Xaml.Grid.GridResourceWrapper.SetResources("Assembly_name", "namespace_name");
    InitializeComponent();
}

Editing default culture resource

You can edit default resource file by adding it to Resources folder of your application where SfDataGrid reads the static texts from here. You can download the default resource file from here.

Displaying the default culture resource editing for WPF SfDataGrid

Now, change the Name/Value pair in Resource Designer of Syncfusion.SfGrid.WPF.resx file.

Displaying the name / value pair in the resource designer for default culture resource in WPF SfDataGrid

Displaying WPF SfDataGrid with the default culture resource edited