diff --git a/AddingCustomResourceFile.png b/AddingCustomResourceFile.png new file mode 100644 index 0000000..5f0eba3 Binary files /dev/null and b/AddingCustomResourceFile.png differ diff --git a/CustomResourceFile.png b/CustomResourceFile.png new file mode 100644 index 0000000..c2411e0 Binary files /dev/null and b/CustomResourceFile.png differ diff --git a/DefaultResourceFile.png b/DefaultResourceFile.png new file mode 100644 index 0000000..6a4dd96 Binary files /dev/null and b/DefaultResourceFile.png differ diff --git a/LocalizationAppliedToDataGrid.png b/LocalizationAppliedToDataGrid.png new file mode 100644 index 0000000..f3317fa Binary files /dev/null and b/LocalizationAppliedToDataGrid.png differ diff --git a/README.md b/README.md index 7afaa66..f9ee5f3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,58 @@ -# Localization in WPF DataGrid (SfDataGrid) +# How to Apply the Localization in WPF DataGrid? -This repository contains sample which shows localization of Syncfusion WPF DataGrid. -https://help.syncfusion.com/wpf/localization +This repository contains sample which shows localization of Syncfusion [WPF DataGrid](https://www.syncfusion.com/wpf-controls/datagrid) (SfDataGrid). -![Localized WPF DataGrid](wpf-datagrid-localization.PNG) +[Localization](https://help.syncfusion.com/wpf/localization) is the process of translating the application resources into different language for the specific cultures. You can localize the WPF DataGrid by adding a resource file for each language. + +### Changing application culture + +When you change the application culture, you can localize the application based on application culture by creating .resx file. + +#### C# + +``` csharp +public partial class MainWindow +{ + public MainWindow() + { + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de"); + InitializeComponent(); + } +} +``` + +#### VB + +``` vb +Partial Public Class MainWindow + Public Sub New() + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de") + InitializeComponent() + End Sub +End Class +``` + +### Creating .resx files + +You can create .resx files for any language by following these steps: + +1. Right-click your project and add a new folder named as `Resources`. + +2. Add the [default resource files](https://github.com/syncfusion/wpf-controls-localization-resx-files) to the libraries you are using to the `Resources` folder and ensure `AccessModifier` is specified as Public. + +**Note:** +Consider, you are using `SfDataGrid` and `Ribbon` in your application. Then, you need to copy and include `Syncfusion.SfGrid.WPF.resx` (since `SfDataGrid` present in `Syncfusion.SfGrid.WPF` library) and `Syncfusion.Tools.Wpf.resx` (since `Ribbon` present in `Syncfusion.Tools.WPF` library) files in your application under `Resources` folder. So, now you can know the key names and values of default stings used in `Syncfusion.Tools.WPF.dll` and `Syncfusion.SfGrid.WPF.dll` libraries. + +![Included the default resource file for localization](DefaultResourceFile.png) + +3. Now, right-click `Resources` folder and select Add and then `NewItem`. In the `Add New Item` wizard, select the Resource File option and name the filename as `Syncfusion.SfGrid.WPF..resx`. For example, you have to give name as `Syncfusion.SfGrid.WPF.de.resx` for `German` culture. In the same way, add new resource files for other libraries used in your application. + +![Adding custom resource file for localization](AddingCustomResourceFile.png) + +4. Now, select Add and add resource file for German culture in `Resources` folder and set `AccessModifier` property to No code generation. + +![Included the custom resource file for localization](CustomResourceFile.png) + +5. Now, you can copy the key names from the default resource files and assign values based on the culture and the resource files’ targets. + +![DataGrid with Localization applied](LocalizationAppliedToDataGrid.png) diff --git a/wpf-datagrid-localization.PNG b/wpf-datagrid-localization.PNG deleted file mode 100644 index 8466947..0000000 Binary files a/wpf-datagrid-localization.PNG and /dev/null differ