Viewer Localization Support

The DynamicPDF Viewer supports localization. Localization is customizing your application to a given culture and locale. Windows provides strong support for localization, and DynamicPDF Viewer is no exception. Adding localization to your DynamicPDF Viewer application is straightforward. When adding localization, you pass the resource using a window's resource manager or specify the resource to load directly using DynamicPDF Viewer code.

Resource Folder

Regardless of how you localize your application, you must create the appropriate resource files that specify the desired languages. To create these files, create a folder named Resources in your project's solution explorer and place the desired resource files. Each file contains the project's properties in the language specified.

Resource files follow the following format: "ceTe.DynamicPDF.Viewer.Localization." where the file extension can be hi-IN, en-UK, etc., for example, ceTe.DynamicPDF.Viewer.Localization.hi-IN is a valid filename for the language.

After creating the required resource files, assign the required culture information to the current thread where the form which uses the DynamicPdf Viewer control. For example, the following code can be added to the form constructor, as illustrated below.

InitializeComponents(): 

System.Threading.Thread.CurrentThread.CurrentUICulture = new
    System.Globalization.CultureInfo("en-IN");
InitializeComponents(): 

System.Threading.Thread.CurrentThread.CurrentUICulture = New
    System.Globalization.CultureInfo("en-IN")

For example, during Viewer initialization, if the Resource folder contains "en-IN," it is loaded.

Windows ResourceManager

You can also use the Windows ResourceManager. To use Microsoft's ResourceManager class (System.Resources.ResourceManager), build a windows forms application and create a resource manager instance. If it finds the specified resource file, the resource manager instance loads the correct resource file and displays the control labels using the user's chosen language.

Refer to the Microsoft article, Globalizing and localizing .NET applications, for more information on adding localization using a ResourceManager.

After creating a ResourceManager instance, you create a new PDFViewer by passing the resource manager instance to the PDFViewer constructor, as the following code illustrates.

PdfViewer myViewer = new PdfViewer(resourcemanager);       
PdfViewer MyViewer = New PdfViewer(resourcemanager)

DynamicPDF Viewer Programmatically

An alternative to a .NET ResourceManager class is to load a resource file at runtime. As before, first, create a Windows forms application. Also, create a folder named Resources under the project in the solution explorer. Place the modified file in the newly created Resources folder. The file name should follow the format: “ceTe.DynamicPDF.Viewer.Localization.” where extension can be hi-IN, en-UK, or other valid language localization extension (e.g. ceTe.DynamicPDF.Viewer.Localization.hi-IN).

After adding the file, assign the required cultural information to the current form’s thread where DynamicPDF Viewer control is used. For example, the following code can be added to the form constructor.

InitializeComponents(): 
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-IN");
InitializeComponents(): 
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-IN")

If a specified culture ("en-IN" in the above example) is present under the Resources folder, it is loaded during the initialization of the Viewer control. The default user interface is displayed if a specified culture is not present. If culture/language requires changing at run time, then you need to create a Viewer control after changing the CurrentUICulture of the thread

In this topic