Localization of Syncfusion® WinUI controls
13 Oct 20253 minutes to read
Localization is the process of making an application multilingual by formatting the content according to the languages. This involves configuring the application for a specific language. For example,
en-US
is the language of English spoken in the United States, while en-GB
is the language of English spoken in Great Britain. Syncfusion® WinUI controls can be localized by adding resource files for each language.
Changing application language
The application language can be changed by setting the desired language to the ApplicationLanguages.PrimaryLanguageOverride
property in the constructor of the main window. Localization can be done while changing the application language by creating a .resw file.
public sealed partial class MainWindow : Window
{
public MainWindow()
{
Microsoft.Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "de"; // Works for the both and unpack deployments.
this.InitializeComponent();
}
}
You can use the below code for packaged deployments. But in unpackaged deployments, it may cause the app to crash.
public sealed partial class MainWindow : Window
{
public MainWindow()
{
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "de"; // This code works for packaged deployments, but in unpackaged deployments, it may cause the app to crash.
this.InitializeComponent();
}
}
NOTE
We recommend setting the above code before the
InitializeComponent
method if you have added a .resw file to your project. Otherwise, it may cause the project to crash.
The following screenshot illustrates how the localization is applied to the datagrid based on the defined language to the ApplicationLanguages.PrimaryLanguageOverride
property.
Creating .resw files
The following steps can be used to generate .resw files for any language:
NOTE
The default resource files of all Syncfusion® WinUI libraries can be obtained from GitHub.
1) Right-click the project and add a New folder named as “Resources”.
2) Add another folder and name the folder with “language name”. For example, “de” for German language. Find the supported culture codes from here.
3) Add default resource files in the following structure.
NOTE
If the
SfDataGrid
control is used in the application, copy and paste theSyncfusion.Grid.WinUI.resw
(SfDataGrid present in the Syncfusion.Grid.WinUI library) file into the application under Resources folder. So, now you know the key names and values of the default strings in the Syncfusion.Grid.WinUI library.
4) Now, the key names from default resource files can be defined and assigned values based on language.
Download demo from GitHub
Editing default language strings
The default string of any control can be changed by adding the default .resw files (from GitHub) to the Resources folder of the application. If the default string is added, Syncfusion® WinUI controls reads it from the .resw files of the application.