Localization in .NET MAUI DataGrid (SfDataGrid)

Localization is the process of translating the application resources into different language for the specific cultures. The SfDataGrid can be localized by adding resource file. In SfDataGrid, provides the support to localize the below strings

  • Load More

Setting CurrentUICulture to the application

Application culture can be changed by setting CurrentUICulture. in App.xaml.cs file.

using Syncfusion.Maui.DataGrid;
using System.Globalization;
using System.Resources;

namespace MauiDataGridDemo;
public partial class App : Application
{
	public App()
	{
		InitializeComponent();
		CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");

		SfDataGridResources.ResourceManager = new ResourceManager("MauiDataGridDemo.Resources.SfDataGrid", Application.Current.GetType().Assembly);
	   MainPage = new MainPage();
	}
}

Load more in MAUI SfDataGrid

NOTE

The required resx files with Build Action as EmbeddedResource (File name should contain culture code) into the Resources folder.

Localize application level

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

  1. Create new folder, named as Resources in the application.

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

  3. In Add New Item wizard, select the Resource File option and name the filename as SfDataGrid.<culture name>.resx. For example, give the name as SfDataGrid.fr-FR.resx for French culture.

  4. The culture name indicates the name of the language and country.

Create resources file in the sample

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

Localization sample

  1. Add the Name/Value pair in Resource Designer of SfDataGrid.fr-FR.resx file and change its corresponding value to corresponding culture.

Resource file