Articles in this section
Category / Section

How to localize Windows Forms controls using Satellite Assemblies in WPF application?

8 mins read

You can localize the WinForms control by following the given steps.

Step 1: The neutral resources of every WinForms component are present in the localization folder of each component’s source code. For the Tools package, the resources are present in the following path, assuming that C:\Program Files\ is the installation path for the Syncfusion components:

 

Tools.Windows:

   C:\Program Files\Syncfusion\Essential Studio<version>\Windows\Tools.Windows\Localization\

             

Shared.Base:

   C:\Program Files\Syncfusion\Essential Studio<version>\Base\Shared.Base\Localization

 

Step 2: In the NeutralResources folder, there are four resource files corresponding to the Tools package. These resources contain the string representations for the English (default and neutral) culture.

 

Step 3: Microsoft Visual Studio.NET provides a tool, Resource Editor (ResEditor) that can be used to localize the string resources. It provides a graphic interface that allows you to construct resource files containing bitmaps, icons, and strings. The following figure shows how the Resource Editor looks when it is first opened.

 

 

Showing resource editor            

                Figure 1: Resource Editor

 

 

Step 4: By using the Resource Editor, open the resource file named Syncfusion.Windows.Forms.Tools.SR.resources present in the NeutralResources folder. The file is opened in the ResEditor as shown in the following image.

 

Showing resource file             

             Figure 2: Resource file 

Step 5: After opening the resource file in the Resource Editor, start entering the equivalent strings for the required culture. In this example, German is used. In the following figure, all the English strings are replaced by their German equivalent. For instance, the German equivalent of Close is & Schließen.

Showing strings in German

                  Figure 3: Strings in German

       

 

Step 6: In ResEditor, Click File > Save As and save the file. The file is saved as Syncfusion.Windows.Forms.Tools.SR.de-DE. You can save it as per your wish.

 

Step 7: Repeat the process for other resources and save it. Now, in the Visual Studio.NET Command Prompt, enter the following command and press Enter. Make sure that you have the sf.publicsnk file from the localization folder.

 

Tools.Windows

  al /t:lib /culture:de-DE /out: Syncfusion.Tools.Windows.resources.dll /v:2.0.0.0 /delay+ /keyf: sf.publicsnk /embed:Syncfusion.Windows.Forms.Tools.SR.de-DE.resources

 

 

 

 

Showing Visual Studio command prompt

                         Figure 4: Visual studio command prompt

Shared.Base

  al /t:lib /culture:de-DE /out: Syncfusion.Shared.Base.resources.dll /v:1.1.0.0 /delay+ /keyf: sf.publicsnk /embed: Syncfusion.Windows.Forms.Localization.SR.de-DE

 

 

Step 8: The version you specify for these DLLs in the al command should be based on the SatelliteContractVersionAttribute setting in the product AssemblyInfo. This also means that when a new version of the product is released (with a newer assembly version), you have to recreate (adding new resources, when available or necessary), and recompile your resource DLLs with a new version (in case the SatelliteContractVersionAttribute has changed).

 

Step 9: On successful execution, an assembly file named Syncfusion.Tools.Windows.resources.dll is created.

 

Step 10: Finally, mark this satellite DLL for verification skipping (since it is not signed with the same strong-name as the product assembly). To do this, enter the following code in the Visual Studio command prompt sn –Vr Syncfusion.Tools.Windows.resources.dll.

Satellite DLL for verification skipping

Figure 5: Satellite DLL for verification skipping

 

Step 11: Drop this DLL into an appropriate sub-directory under yours. EXE’s directory (bin\Debug), based on the naming conventions enforced in .NET. You should put it in the de-DE sub-directory in case this DLL contains resources from the German (Germany) culture.

 

Step 12: Finally, you should make your application fetch the German resources during run time. The following sample code does that. To change the UI culture of the current thread, add this code in the Forms constructor before the InitializeComponent ().

 

C#

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

 

Step 13: Now, run your application containing the Syncfusion Toolbar and Menu controls. The localization is applied to the Syncfusion controls as shown in the following images.

 

Localization in GroupBar

Figure 6: Localization in GroupBar

 

Localization in MainFrameBarManager

Figure 7: Localization in MainFrameBarManager

 

Localization in Customization dialog box

Figure 8: Localization in Customization dialog box

Localization in DockingManager

Figure 9: Localization in DockingManager

 

Sample Links:

C#: How to Localize WinForm controls C#

 

VB: How to Localize WinForm controls VB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied