Localization in WPF Spreadsheet (SfSpreadsheet)

4 Apr 20242 minutes to read

Localization is the process of configuring the application to a specific language. SfSpreadsheet provides support to localize all the static text in a Ribbon and all dialogs to any desired language. Localization can be done by adding resource file and setting the specific culture in the application.

SfSpreadsheet allows you to set custom resource using Resx file. You can define your string values in resource file for a specific culture and set the culture in your application.

Set Current UI Culture to the Application

To set the CultureInformation in the Application, set the CurrentUICulture before the InitializeComponent() method is called.

Setting of the culture information,

public MainWindow()
{
    System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja-JP");
    InitializeComponent();
}

Now, the Application is set to the Japanese Culture info.

Localization using Resource file

The following steps show how to implement the localization in SfSpreadsheet,

  • Create a folder and name it as ‘Resources’ in your application.
  • Add the default resource[English(“en-US”)] file of SfSpreadsheet in the ‘Resources’ folder named as Syncfusion.SfSpreadsheet.WPF.resx.
    You can download the Resx file here
  • Create Resx(resource) file under the ‘Resources’ folder and name it as Syncfusion.SfSpreadsheet.WPF.[Culture name].resx.
    For example, Syncfusion.SfSpreadsheet.WPF.ja.resx for Japanese culture.

WPF Spreadsheet Localization using Resource File

  • Add the resource key such as name and its corresponding localized value in Resource Designer of Syncfusion.SfSpreadsheet.WPF.ja.resx file.
    For your reference, you can download the Japanese(“ja-JP”) Resx file here

WPF Spreadsheet Localization with Resource Key

The following screenshot shows you the localization in SfSpreadsheet,

WPF Spreadsheet Localization

Modifying the localized strings in Resource file

Users can modify the default localized strings in Resource file by adding the default Resx (resource) file of SfSpreadsheet in the ‘Resources’ folder of your application and name it as Syncfusion.SfSpreadsheet.WPF.resx.

Now, the default localized strings can be modified by changing the Name/Value pair in the Syncfusion.SfSpreadsheet.WPF.resx file.

WPF Spreadsheet Localized using Resource String

NOTE

You can refer to our WPF Spreadsheet feature tour page for its groundbreaking feature representations. You can also explore our WPF Spreadsheet example to know how to render and configure the spreadsheet.

Localize when the resource file is present in a different assembly or different namespace

WPF-Spreadsheet (SfSpreadsheet) reads the localization resource files based on the assembly name from its default namespace. If you have the localization resource file other than the executing assembly (Assembly.GetExecutingAssembly())or other than the default namespace, then you have to pass the assembly having the resource file and its default namespace to GridResourceWrapper.SetResources method.

public MainWindow()
 {
      System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja");
      Assembly assembly = Assembly.Load("Another assemblyname having resource file");
      Syncfusion.UI.Xaml.Spreadsheet.Resources.GridResourceWrapper.SetResources(assembly, "namespacename");
      InitializeComponent();
 }